diff options
author | Stan Hu <stanhu@gmail.com> | 2017-08-03 02:58:28 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-08-03 02:58:28 +0300 |
commit | 408df2edcbd5f3f93ef5541bac9de2b71ba4f0ea (patch) | |
tree | 708ae61f9683b48f436f7577d1fad98f30e100fc /spec/support/capybara.rb | |
parent | 3f81586ef0ab20533b8da1213bd9f60e1786dbaa (diff) | |
parent | faa2a123911eaf84bb57163ea7af759d4632601b (diff) |
Merge branch 'master' into sh-headless-chrome-support
Diffstat (limited to 'spec/support/capybara.rb')
-rw-r--r-- | spec/support/capybara.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index 4a4b037d0b1..53a90cdb26f 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -37,12 +37,20 @@ RSpec.configure do |config| $capybara_server_already_started = true end - config.after(:each, :js) do + config.before(:example, :js) do + allow(Gitlab::Application.routes).to receive(:default_url_options).and_return( + host: Capybara.current_session.server.host, + port: Capybara.current_session.server.port, + protocol: 'http') + end + + config.after(:example, :js) do |example| # capybara/rspec already calls Capybara.reset_sessions! in an `after` hook, # but `block_and_wait_for_requests_complete` is called before it so by # calling it explicitely here, we prevent any new requests from being fired # See https://github.com/teamcapybara/capybara/blob/ffb41cfad620de1961bb49b1562a9fa9b28c0903/lib/capybara/rspec.rb#L20-L25 - Capybara.reset_sessions! + # We don't reset the session when the example failed, because we need capybara-screenshot to have access to it. + Capybara.reset_sessions! unless example.exception block_and_wait_for_requests_complete end end |