debian-mirror-gitlab/spec/support/matchers/have_gitlab_http_status.rb

21 lines
641 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
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|
2018-03-17 18:26:18 +05:30
# 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-09-10 17:25:29 +05:30
"expected the response to have status code #{expected.inspect}" \
2018-03-17 18:26:18 +05:30
" but it was #{response_code}. The response was: #{actual.body}"
2017-09-10 17:25:29 +05:30
end
end