Skip to content

Commit

Permalink
Set capybara as the default host in system specs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed May 25, 2020
1 parent 0896526 commit 49b14cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rspec/rails/example/system_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def driven_by(driver, **driver_options, &blk)

before do
@routes = ::Rails.application.routes
default_url_options.merge!(host: Capybara.app_host)
end

after do
Expand Down
34 changes: 34 additions & 0 deletions spec/rspec/rails/example/system_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,40 @@ module RSpec::Rails
end
end

describe 'rails url helpers' do
it 'have the rails system test default host' do
full_url = nil
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup

specify do
@routes.draw { get "/" => "page#index", as: :root }
full_url = root_url
end
end
group.run(failure_reporter)
expect(failure_reporter.exceptions).to eq []
expect(full_url).to match a_string_including(ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown::DEFAULT_HOST)
end
end

describe '#url_options' do
it 'has the rails system test default host' do
rails_url_options = {}
group = RSpec::Core::ExampleGroup.describe do
include SystemExampleGroup

specify { rails_url_options.merge!(url_options) }
end
group.run(failure_reporter)
expect(failure_reporter.exceptions).to eq []

expect(
rails_url_options
).to match hash_including(host: ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown::DEFAULT_HOST)
end
end

describe '#driver' do
it 'uses :selenium driver by default' do
group = RSpec::Core::ExampleGroup.describe do
Expand Down

0 comments on commit 49b14cb

Please sign in to comment.