2017-07-14 13:43:26 -04:00
|
|
|
RSpec::Matchers.define :have_gitlab_http_status do |expected|
|
|
|
|
match do |actual|
|
|
|
|
expect(actual).to have_http_status(expected)
|
|
|
|
end
|
|
|
|
|
|
|
|
description do
|
|
|
|
"respond with numeric status code #{expected}"
|
|
|
|
end
|
|
|
|
|
|
|
|
failure_message do |actual|
|
2017-11-23 08:16:14 -05:00
|
|
|
# actual can be either an ActionDispatch::TestResponse (which uses #response_code)
|
|
|
|
# or a Capybara::Session (which uses #status_code)
|
|
|
|
response_code = actual.try(:response_code) || actual.try(:status_code)
|
|
|
|
|
2017-07-14 13:43:26 -04:00
|
|
|
"expected the response to have status code #{expected.inspect}" \
|
2017-11-23 08:16:14 -05:00
|
|
|
" but it was #{response_code}. The response was: #{actual.body}"
|
2017-07-14 13:43:26 -04:00
|
|
|
end
|
|
|
|
end
|