Dry out code with shared_examples
This commit is contained in:
parent
4b3345586a
commit
f28a05ede2
|
|
@ -80,22 +80,23 @@ RSpec.describe MatchScoresController, type: :controller do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when successful' do
|
shared_examples_for 'update_of_match_score' do
|
||||||
let(:context) { double(:context, success?: true) }
|
|
||||||
|
|
||||||
it 'returns a 200 status code' do
|
it 'returns a 200 status code' do
|
||||||
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when successful' do
|
||||||
|
let(:context) { double(:context, success?: true) }
|
||||||
|
|
||||||
|
it_should_behave_like 'update_of_match_score'
|
||||||
|
end
|
||||||
|
|
||||||
context 'when unsuccessful' do
|
context 'when unsuccessful' do
|
||||||
let(:context) { double(:context, success?: false) }
|
let(:context) { double(:context, success?: false) }
|
||||||
|
|
||||||
it 'returns a 200 status code' do
|
it_should_behave_like 'update_of_match_score'
|
||||||
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
|
||||||
expect(response).to be_successful
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue