Permalink
Browse files

Rename system_test_helper -> application_system_test_case

This renames the system test helper file to be application system test
case to match what the rest of Rails does. In the future we should
consider changing the test_helper to match.
  • Loading branch information...
eileencodes committed Feb 20, 2017
1 parent 161cf89 commit 2d61c5d846f8dd3a02080fedce7ab63b8d314db6
@@ -17,12 +17,12 @@ class SystemTestCase < IntegrationTest
# 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,36 +36,28 @@ class SystemTestCase < IntegrationTest
# 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.
#
# 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,19 +66,14 @@ class SystemTestCase < IntegrationTest
#
# 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"
# require "capybara/poltergeist"
#
# 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
@@ -17,9 +17,9 @@ def take_screenshot
# 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?
View
@@ -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
```
@@ -153,7 +153,7 @@ def test
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
@@ -6,8 +6,8 @@ class SystemGenerator < Base # :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")
@@ -1,4 +1,4 @@
-require "system_test_helper"
+require "application_system_test_case"
class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
# test "visiting the index" do

0 comments on commit 2d61c5d

Please sign in to comment.