aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/system_test_case.rb25
-rw-r--r--actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb6
-rw-r--r--guides/source/testing.md24
-rw-r--r--railties/lib/rails/generators/rails/app/app_generator.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb (renamed from railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb)0
-rw-r--r--railties/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb (renamed from railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb)0
-rw-r--r--railties/lib/rails/generators/test_unit/system/system_generator.rb4
-rw-r--r--railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb (renamed from railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb)0
-rw-r--r--railties/lib/rails/generators/test_unit/system/templates/system_test.rb2
9 files changed, 25 insertions, 38 deletions
diff --git a/actionpack/lib/action_dispatch/system_test_case.rb b/actionpack/lib/action_dispatch/system_test_case.rb
index 91cbc1180c..ca23cab6ae 100644
--- a/actionpack/lib/action_dispatch/system_test_case.rb
+++ b/actionpack/lib/action_dispatch/system_test_case.rb
@@ -17,12 +17,12 @@ module ActionDispatch
# To create a system test in your application, extend your test class
# from <tt>ApplicationSystemTestCase</tt>. System tests use Capybara as a
# base and allow you to configure the settings through your
- # <tt>system_test_helper.rb</tt> file that is generated with a new
+ # <tt>application_system_test_case.rb</tt> file that is generated with a new
# application or scaffold.
#
# Here is an example system test:
#
- # require 'system_test_helper'
+ # require 'application_system_test_case'
#
# class Users::CreateTest < ApplicationSystemTestCase
# test "adding a new user" do
@@ -36,7 +36,7 @@ module ActionDispatch
# end
# end
#
- # When generating an application or scaffold a +system_test_helper.rb+ will also
+ # When generating an application or scaffold a +application_system_test_case.rb+ will also
# be generated containing the base class for system testing. This is where you
# can change the driver, add Capybara settings, and other configuration for
# your system tests.
@@ -44,28 +44,20 @@ module ActionDispatch
# require "test_helper"
#
# class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
- # teardown do
- # take_failed_screenshot
- # Capybara.reset_sessions!
- # end
+ # driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
# end
#
# By default, <tt>ActionDispatch::SystemTestCase</tt> is driven by the
# Selenium driver, with the Chrome browser, and a browser size of 1400x1400.
#
# Changing the driver configuration options are easy. Let's say you want to use
- # and the Firefox browser instead. In your +system_test_helper.rb+
+ # and the Firefox browser instead. In your +application_system_test_case.rb+
# file add the following:
#
# require "test_helper"
#
# class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
# driven_by :selenium, using: :firefox
- #
- # teardown do
- # take_failed_screenshot
- # Capybara.reset_sessions!
- # end
# end
#
# +driven_by+ has a required argument for the driver name. The keyword
@@ -74,7 +66,7 @@ module ActionDispatch
#
# To use a headless driver, like Poltergeist, update your Gemfile to use
# Poltergeist instead of Selenium and then declare the driver name in the
- # +system_test_helper.rb+ file. In this case you would leave out the +:using+
+ # +application_system_test_case.rb+ file. In this case you would leave out the +:using+
# option because the driver is headless.
#
# require "test_helper"
@@ -82,11 +74,6 @@ module ActionDispatch
#
# class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
# driven_by :poltergeist
- #
- # teardown do
- # take_failed_screenshot
- # Capybara.reset_sessions!
- # end
# end
#
# Because <tt>ActionDispatch::SystemTestCase</tt> is a shim between Capybara
diff --git a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
index ab14910b41..784005cb93 100644
--- a/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
+++ b/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb
@@ -17,9 +17,9 @@ module ActionDispatch
# Takes a screenshot of the current page in the browser if the test
# failed.
#
- # +take_failed_screenshot+ is included in <tt>system_test_helper.rb</tt> that is
- # generated with the application. To take screenshots when a test fails
- # add +take_failed_screenshot+ to the teardown block before clearing
+ # +take_failed_screenshot+ is included in <tt>application_system_test_case.rb</tt>
+ # that is generated with the application. To take screenshots when a test
+ # fails add +take_failed_screenshot+ to the teardown block before clearing
# sessions.
def take_failed_screenshot
take_screenshot unless passed?
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 366ab0b2a1..fe0dbf6c50 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -34,7 +34,7 @@ Rails creates a `test` directory for you as soon as you create a Rails project u
```bash
$ ls -F test
controllers/ helpers/ mailers/ system/ test_helper.rb
-fixtures/ integration/ models/ system_test_helper.rb
+fixtures/ integration/ models/ application_system_test_case.rb
```
The `helpers`, `mailers`, and `models` directories are meant to hold tests for view helpers, mailers, and models, respectively. The `controllers` directory is meant to hold tests for controllers, routes, and views. The `integration` directory is meant to hold tests for interactions between controllers.
@@ -51,7 +51,7 @@ A `jobs` directory will also be created when an associated test is first generat
The `test_helper.rb` file holds the default configuration for your tests.
-The `system_test_helper.rb` holds the default configuration for your system
+The `application_system_test_case.rb` holds the default configuration for your system
tests.
@@ -618,12 +618,12 @@ $ bin/rails generate system_test users_create_test.rb
Here's what a freshly-generated system test looks like:
```ruby
-require "system_test_helper"
+require "application_system_test_case"
class UsersCreateTest < ApplicationSystemTestCase
- # test "the truth" do
- # assert true
- # end
+ visit users_url
+
+ assert_selector "h1", text: "Users"
end
```
@@ -636,14 +636,14 @@ section explains how to change the default settings.
Rails makes changing the default settings for system test very simple. All
the setup is abstracted away so you can focus on writing your tests.
-When you generate a new application or scaffold, a `system_test_helper.rb` file
+When you generate a new application or scaffold, a `application_system_test_case.rb` file
is created in the test directory. This is where all the configuration for your
system tests should live.
If you want to change the default settings you can simple change what the system
tests are "driven by". Say you want to change the driver from Selenium to
Poltergeist. First add the Poltergeist gem to your Gemfile. Then in your
-`system_test_helper.rb` file do the following:
+`application_system_test_case.rb` file do the following:
```ruby
require "test_helper"
@@ -672,7 +672,7 @@ be used for non-headless drivers like Selenium), `:on` for the port Puma should
use, and `:screen_size` to change the size of the screen for screenshots.
If your Capybara configuration requires more setup than provided by Rails, all
-of that configuration can be put into the `system_test_helper.rb` file provided
+of that configuration can be put into the `application_system_test_case.rb` file provided
by Rails.
Please see [Capybara's documentation](https://github.com/teamcapybara/capybara#setup)
@@ -685,7 +685,7 @@ This can be helpful for viewing the browser at the point a test failed, or
to view screenshots later for debugging.
Two methods are provided: `take_screenshot` and `take_failed_screenshot`.
-`take_failed_screenshot` is automatically included in the `system_test_helper.rb`
+`take_failed_screenshot` is automatically included in the `application_system_test_case.rb`
file and will take a screenshot only if the test fails.
The `take_screenshot` helper method can be included anywhere in your tests to
@@ -715,12 +715,12 @@ previous command we should see:
Now let's open that file and write our first assertion:
```ruby
-require "system_test_helper"
+require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
test "viewing the index" do
visit articles_path
- assert_text "h1", "Articles"
+ assert_selector "h1", text: "Articles"
end
end
```
diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb
index acdb66ca85..18e48c8016 100644
--- a/railties/lib/rails/generators/rails/app/app_generator.rb
+++ b/railties/lib/rails/generators/rails/app/app_generator.rb
@@ -153,7 +153,7 @@ module Rails
def system_test
empty_directory_with_keep_file "test/system"
- template "test/system_test_helper.rb"
+ template "test/application_system_test_case.rb"
end
def tmp
diff --git a/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb b/railties/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb
index d19212abd5..d19212abd5 100644
--- a/railties/lib/rails/generators/rails/app/templates/test/system_test_helper.rb
+++ b/railties/lib/rails/generators/rails/app/templates/test/application_system_test_case.rb
diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb
index d19212abd5..d19212abd5 100644
--- a/railties/lib/rails/generators/rails/plugin/templates/test/system_test_helper.rb
+++ b/railties/lib/rails/generators/rails/plugin/templates/test/application_system_test_case.rb
diff --git a/railties/lib/rails/generators/test_unit/system/system_generator.rb b/railties/lib/rails/generators/test_unit/system/system_generator.rb
index e77ccef009..aec415a4e5 100644
--- a/railties/lib/rails/generators/test_unit/system/system_generator.rb
+++ b/railties/lib/rails/generators/test_unit/system/system_generator.rb
@@ -6,8 +6,8 @@ module TestUnit # :nodoc:
check_class_collision suffix: "Test"
def create_test_files
- if !File.exist?(File.join("test/system_test_helper.rb"))
- template "system_test_helper.rb", File.join("test", "system_test_helper.rb")
+ if !File.exist?(File.join("test/application_system_test_case.rb"))
+ template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
end
template "system_test.rb", File.join("test/system", "#{file_name.pluralize}_test.rb")
diff --git a/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb b/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb
index d19212abd5..d19212abd5 100644
--- a/railties/lib/rails/generators/test_unit/system/templates/system_test_helper.rb
+++ b/railties/lib/rails/generators/test_unit/system/templates/application_system_test_case.rb
diff --git a/railties/lib/rails/generators/test_unit/system/templates/system_test.rb b/railties/lib/rails/generators/test_unit/system/templates/system_test.rb
index 2afc7a4aac..b5ce2ba5c8 100644
--- a/railties/lib/rails/generators/test_unit/system/templates/system_test.rb
+++ b/railties/lib/rails/generators/test_unit/system/templates/system_test.rb
@@ -1,4 +1,4 @@
-require "system_test_helper"
+require "application_system_test_case"
class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
# test "visiting the index" do