diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-17 09:29:36 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-17 09:29:36 +0000 |
commit | 683fd52c59497b6c0c2ddb8933c47fca5651a614 (patch) | |
tree | 9110dd495f54494c3549417781143bf9d7adb317 | |
parent | 5f32bd774ad5cb89685dab5102e0614b2593d4ff (diff) | |
parent | 0fd4a6b637e30adc9855e7cea1c53c4767fcefcb (diff) | |
download | gitlab-ce-683fd52c59497b6c0c2ddb8933c47fca5651a614.tar.gz |
Merge branch '34964-have_gitlab_http_status' into 'master'
Introduce have_gitlab_http_status
Closes #34964
See merge request !12883
-rw-r--r-- | spec/requests/api/version_spec.rb | 4 | ||||
-rw-r--r-- | spec/support/matchers/have_gitlab_http_status.rb | 14 |
2 files changed, 16 insertions, 2 deletions
diff --git a/spec/requests/api/version_spec.rb b/spec/requests/api/version_spec.rb index 8870d48bbc9..7bbf34422b8 100644 --- a/spec/requests/api/version_spec.rb +++ b/spec/requests/api/version_spec.rb @@ -6,7 +6,7 @@ describe API::Version do it 'returns authentication error' do get api('/version') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -16,7 +16,7 @@ describe API::Version do it 'returns the version information' do get api('/version', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['version']).to eq(Gitlab::VERSION) expect(json_response['revision']).to eq(Gitlab::REVISION) end diff --git a/spec/support/matchers/have_gitlab_http_status.rb b/spec/support/matchers/have_gitlab_http_status.rb new file mode 100644 index 00000000000..3198f1b9edd --- /dev/null +++ b/spec/support/matchers/have_gitlab_http_status.rb @@ -0,0 +1,14 @@ +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| + "expected the response to have status code #{expected.inspect}" \ + " but it was #{actual.response_code}. The response was: #{actual.body}" + end +end |