diff options
author | Rémy Coutable <remy@rymai.me> | 2017-07-26 15:33:09 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-27 15:29:31 +0300 |
commit | 649382b1c27b09e5b54a5cdb21f078f37ecd7306 (patch) | |
tree | 870cd9927fdb61fe258d46976d4daf43ff5bda0b /spec/support/api | |
parent | 4eebd8e1957a3fc3a3479331fde9f34aa8afa9d5 (diff) |
Fix the /projects/:id/repository/branches endpoint to handle dots in the branch name when the project full patch contains a `/`
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/support/api')
-rw-r--r-- | spec/support/api/schema_matcher.rb | 9 | ||||
-rw-r--r-- | spec/support/api/status_shared_examples.rb | 42 |
2 files changed, 8 insertions, 43 deletions
diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb index dff0dfba675..67599f77adb 100644 --- a/spec/support/api/schema_matcher.rb +++ b/spec/support/api/schema_matcher.rb @@ -5,7 +5,14 @@ end RSpec::Matchers.define :match_response_schema do |schema, **options| match do |response| - JSON::Validator.validate!(schema_path(schema), response.body, options) + @errors = JSON::Validator.fully_validate(schema_path(schema), response.body, options) + + @errors.empty? + end + + failure_message do |response| + "didn't match the schema defined by #{schema_path(schema)}" \ + " The validation errors were:\n#{@errors.join("\n")}" end end diff --git a/spec/support/api/status_shared_examples.rb b/spec/support/api/status_shared_examples.rb deleted file mode 100644 index 3481749a7f0..00000000000 --- a/spec/support/api/status_shared_examples.rb +++ /dev/null @@ -1,42 +0,0 @@ -# Specs for status checking. -# -# Requires an API request: -# let(:request) { get api("/projects/#{project.id}/repository/branches", user) } -shared_examples_for '400 response' do - before do - # Fires the request - request - end - - it 'returns 400' do - expect(response).to have_http_status(400) - end -end - -shared_examples_for '403 response' do - before do - # Fires the request - request - end - - it 'returns 403' do - expect(response).to have_http_status(403) - end -end - -shared_examples_for '404 response' do - let(:message) { nil } - before do - # Fires the request - request - end - - it 'returns 404' do - expect(response).to have_http_status(404) - expect(json_response).to be_an Object - - if message.present? - expect(json_response['message']).to eq(message) - end - end -end |