diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/capybara.rb | 21 | ||||
-rw-r--r-- | spec/support/login_helpers.rb | 2 | ||||
-rw-r--r-- | spec/support/stub_gitlab_calls.rb | 6 | ||||
-rw-r--r-- | spec/support/webmock.rb | 4 |
4 files changed, 29 insertions, 4 deletions
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb new file mode 100644 index 0000000..fed1ab6 --- /dev/null +++ b/spec/support/capybara.rb @@ -0,0 +1,21 @@ +require 'capybara/rails' +require 'capybara/rspec' +require 'capybara/poltergeist' + +# Give CI some extra time +timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 90 : 10 + +Capybara.javascript_driver = :poltergeist +Capybara.register_driver :poltergeist do |app| + Capybara::Poltergeist::Driver.new(app, js_errors: true, timeout: timeout) +end + +Capybara.default_wait_time = timeout +Capybara.ignore_hidden_elements = true + +unless ENV['CI'] || ENV['CI_SERVER'] + require 'capybara-screenshot/rspec' + + # Keep only the screenshots generated from the last failing test suite + Capybara::Screenshot.prune_strategy = :keep_last_run +end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index ebd9693..fde02b4 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -17,6 +17,6 @@ module LoginHelpers end def skip_admin_auth - ApplicationController.any_instance.stub(authenticate_admin!: true) + allow_any_instance_of(ApplicationController).to receive_messages(authenticate_admin!: true) end end diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb index 931ef96..7760f9c 100644 --- a/spec/support/stub_gitlab_calls.rb +++ b/spec/support/stub_gitlab_calls.rb @@ -10,7 +10,7 @@ module StubGitlabCalls end def stub_js_gitlab_calls - Network.any_instance.stub(:projects) { project_hash_array } + allow_any_instance_of(Network).to receive(:projects) { project_hash_array } end private @@ -42,12 +42,12 @@ module StubGitlabCalls def stub_project_8 data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json')) - Network.any_instance.stub(:project).and_return(JSON.parse(data)) + allow_any_instance_of(Network).to receive(:project).and_return(JSON.parse(data)) end def stub_project_8_hooks data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8_hooks.json')) - Network.any_instance.stub(:project_hooks).and_return(JSON.parse(data)) + allow_any_instance_of(Network).to receive(:project_hooks).and_return(JSON.parse(data)) end def stub_projects diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb new file mode 100644 index 0000000..af2906b --- /dev/null +++ b/spec/support/webmock.rb @@ -0,0 +1,4 @@ +require 'webmock' +require 'webmock/rspec' + +WebMock.disable_net_connect!(allow_localhost: true) |