From 161cf89e134267f9b579f493ca19b12c30d5fd36 Mon Sep 17 00:00:00 2001 From: eileencodes Date: Sun, 19 Feb 2017 17:49:21 -0500 Subject: Fix default host in setup, move teardown to helper file * Override integration test default host Integration tests automatically set the default host to 'http://example.com'. This works fine for integration tests because they are not real browser sessions, but doesn't work fine for system tests because they are real browser sessions. We can override this by setting the `host!` in `before_setup. The `Capybara.always_include_port` will allow the test to look at `127.0.0.1:port capybara picks` and properly redirect the test. Any application can override this by setting the `host!` in their system test helper. Generally though, applications are going to be using localhost. In this commit I also moved the setup and teardown into their own module for tidiness. * Move teardown settings into system test case These configuration options can be put into the system test case file instead of the generated system tests helper file. This is an implementation detail and therefore shouldn't be generated with the template. --- .../rails/generators/rails/app/templates/test/system_test_helper.rb | 5 ----- .../generators/rails/plugin/templates/test/system_test_helper.rb | 5 ----- .../generators/test_unit/system/templates/system_test_helper.rb | 5 ----- 3 files changed, 15 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb b/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb index 440689b503..d19212abd5 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb +++ b/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb @@ -2,9 +2,4 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] - - teardown do - take_failed_screenshot - Capybara.reset_sessions! - end end diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb index 440689b503..d19212abd5 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb @@ -2,9 +2,4 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] - - teardown do - take_failed_screenshot - Capybara.reset_sessions! - end end diff --git a/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb b/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb index 440689b503..d19212abd5 100644 --- a/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb +++ b/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb @@ -2,9 +2,4 @@ require "test_helper" class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400] - - teardown do - take_failed_screenshot - Capybara.reset_sessions! - end end -- cgit v1.2.3