diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2017-04-02 19:06:58 +0900 |
---|---|---|
committer | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2017-04-02 21:11:54 +0900 |
commit | 4c94d3e0a09151a84c5bc1eb044b082e2b07993f (patch) | |
tree | 23f67c36ccdc9cd6053305a72b394fd5e2c81b2d /actionpack/test | |
parent | 19ae6597b844e11842971c4f9298d5fc7014704d (diff) | |
download | rails-4c94d3e0a09151a84c5bc1eb044b082e2b07993f.tar.gz rails-4c94d3e0a09151a84c5bc1eb044b082e2b07993f.tar.bz2 rails-4c94d3e0a09151a84c5bc1eb044b082e2b07993f.zip |
Set `Capybara.app_host` through `host!`
`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`:
https://github.com/teamcapybara/capybara/blob/866c975076f92b5d064ee8998be638dd213f0724/lib/capybara/session.rb#L239
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/dispatch/system_testing/system_test_case_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/system_testing/system_test_case_test.rb b/actionpack/test/dispatch/system_testing/system_test_case_test.rb index 33d98f924f..8f90e45f5f 100644 --- a/actionpack/test/dispatch/system_testing/system_test_case_test.rb +++ b/actionpack/test/dispatch/system_testing/system_test_case_test.rb @@ -19,3 +19,15 @@ class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome 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 |