mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
4c94d3e0a0
`visit "/"` will visit always "http://127.0.0.1" even when we call `host!`:
```ruby
class SomeTest < ApplicationSystemTest
def setup
host! "http://example.com"
end
def test_visit
visit root_url # => visit "http://example.com/"
visit "/" # => visit "http://127.0.0.1/"
end
end
```
Because Capybara assumes that host is same as the server if we don't set `Capybara.app_host`:
866c975076/lib/capybara/session.rb (L239)
33 lines
757 B
Ruby
33 lines
757 B
Ruby
require "abstract_unit"
|
|
|
|
class SetDriverToRackTestTest < DrivenByRackTest
|
|
test "uses rack_test" do
|
|
assert_equal :rack_test, Capybara.current_driver
|
|
end
|
|
end
|
|
|
|
class OverrideSeleniumSubclassToRackTestTest < DrivenBySeleniumWithChrome
|
|
driven_by :rack_test
|
|
|
|
test "uses rack_test" do
|
|
assert_equal :rack_test, Capybara.current_driver
|
|
end
|
|
end
|
|
|
|
class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome
|
|
test "uses selenium" do
|
|
assert_equal :selenium, Capybara.current_driver
|
|
end
|
|
end
|
|
|
|
class SetHostTest < DrivenByRackTest
|
|
test "sets default host" do
|
|
assert_equal "http://127.0.0.1", Capybara.app_host
|
|
end
|
|
|
|
test "overrides host" do
|
|
host! "http://example.com"
|
|
|
|
assert_equal "http://example.com", Capybara.app_host
|
|
end
|
|
end
|