diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-08-07 09:13:10 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-08-07 09:13:10 +0000 |
commit | 727b6d16e5e11933c0879cfa9ed5eb3bb9280cf1 (patch) | |
tree | 16649f5e4d23fb0a0d5f0b28cb25890d7999f493 /spec/support | |
parent | 4b34720c0ca8b5459cc56a4e52e11e213ab6ae9a (diff) | |
parent | 440dc934dec31b4ef3ee78e5ae366f832719b173 (diff) | |
download | gitlab-ce-727b6d16e5e11933c0879cfa9ed5eb3bb9280cf1.tar.gz |
Merge branch 'master' into 'bvl-nfs-circuitbreaker'
# Conflicts:
# app/models/repository.rb
# spec/models/repository_spec.rb
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/api/schema_matcher.rb | 18 | ||||
-rw-r--r-- | spec/support/login_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/test_env.rb | 1 |
3 files changed, 12 insertions, 9 deletions
diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb index 67599f77adb..6591d56e473 100644 --- a/spec/support/api/schema_matcher.rb +++ b/spec/support/api/schema_matcher.rb @@ -1,23 +1,25 @@ -def schema_path(schema) - schema_directory = "#{Dir.pwd}/spec/fixtures/api/schemas" - "#{schema_directory}/#{schema}.json" +module SchemaPath + def self.expand(schema, dir = '') + Rails.root.join('spec', dir, "fixtures/api/schemas/#{schema}.json").to_s + end end -RSpec::Matchers.define :match_response_schema do |schema, **options| +RSpec::Matchers.define :match_response_schema do |schema, dir: '', **options| match do |response| - @errors = JSON::Validator.fully_validate(schema_path(schema), response.body, options) + @errors = JSON::Validator.fully_validate( + SchemaPath.expand(schema, dir), response.body, options) @errors.empty? end failure_message do |response| - "didn't match the schema defined by #{schema_path(schema)}" \ + "didn't match the schema defined by #{SchemaPath.expand(schema, dir)}" \ " The validation errors were:\n#{@errors.join("\n")}" end end -RSpec::Matchers.define :match_schema do |schema, **options| +RSpec::Matchers.define :match_schema do |schema, dir: '', **options| match do |data| - JSON::Validator.validate!(schema_path(schema), data, options) + JSON::Validator.validate!(SchemaPath.expand(schema, dir), data, options) end end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index c714d1b08a6..3e117530151 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -1,3 +1,5 @@ +require_relative 'devise_helpers' + module LoginHelpers include DeviseHelpers diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index bed78928f14..c1298ed9cae 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -229,7 +229,6 @@ module TestEnv # Otherwise they'd be created by the first test, often timing out and # causing a transient test failure def eager_load_driver_server - return unless ENV['CI'] return unless defined?(Capybara) puts "Starting the Capybara driver server..." |