gitlab-org--gitlab-foss/spec/support/json_response_helpers.rb
Rémy Coutable 5f7592d538 Implement json_response as a let variable
This is not a good idea to memoize `json_response` using an instance
variable because `rspec-retry` doesn't clear instance variables on
retries, only `let` variables.

This will avoid issues where retries would fail on a different line that
the original failure, blurrying what's the real failure.

Also, automatically add api: true to specs under
/spec/requests/(ci/)?api/, and include JsonHelpers in controller, request
and API specs.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-13 17:33:17 +01:00

9 lines
287 B
Ruby

shared_context 'JSON response' do
let(:json_response) { JSON.parse(response.body) }
end
RSpec.configure do |config|
config.include_context 'JSON response', type: :controller
config.include_context 'JSON response', type: :request
config.include_context 'JSON response', :api
end