-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Simon
committed
Jul 27, 2020
1 parent
f9099f1
commit 9344c14
Showing
5 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,50 @@ | ||
RSpec.describe Web::Controllers::Interviews::::Index, type: :action do | ||
let(:action) { described_class.new } | ||
let(:params) { Hash[] } | ||
RSpec.describe Web::Controllers::Interviews::Index, type: :action do | ||
subject { action.call(params) } | ||
|
||
it 'is successful' do | ||
response = action.call(params) | ||
expect(response[0]).to eq 200 | ||
let(:action) { described_class.new(operation: operation, interview_operation: interview_operation) } | ||
|
||
let(:params) { { id: 0 } } | ||
|
||
context 'when operation returns success value' do | ||
let(:operation) { ->(*) { Success(Company.new(id: 0)) } } | ||
let(:interview_operation) { ->(*) { Success([Interview.new]) } } | ||
|
||
it { expect(subject).to be_success } | ||
|
||
it 'call operation with a right contract' do | ||
expect(operation).to receive(:call).with(id: 0) | ||
subject | ||
end | ||
|
||
it 'exposes vacancy' do | ||
subject | ||
expect(action.company).to eq(Company.new(id: 0)) | ||
expect(action.interviews).to eq([Interview.new]) | ||
end | ||
end | ||
|
||
context 'when operation returns failure value' do | ||
let(:operation) { ->(*) { Failure(:not_found) } } | ||
let(:interview_operation) { ->(*) { Success([Interview.new]) } } | ||
|
||
it { expect(subject).to redirect_to '/companies' } | ||
|
||
it 'call operation with a right contract' do | ||
expect(operation).to receive(:call).with(id: 0) | ||
subject | ||
end | ||
end | ||
|
||
context 'with real dependencies' do | ||
subject { action.call(params) } | ||
|
||
let(:action) { described_class.new } | ||
let(:params) { { id: company.id } } | ||
|
||
let(:company) { Fabricate.create(:company) } | ||
|
||
before { Fabricate(:review, company_id: company.id) } | ||
|
||
it { expect(subject).to be_success } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters