aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/testing.md
diff options
context:
space:
mode:
authorPierre Hedkvist <pierre.hedkvist@gmail.com>2017-11-27 12:24:29 +0000
committerPierre Hedkvist <pierre.hedkvist@gmail.com>2017-12-04 10:22:31 +0100
commit18dba79bf27a370c823b34380120bff49cec08e2 (patch)
treef5c9c630ae251121c9d7c7279a5cf44a490d14ad /guides/source/testing.md
parent07788c7ad8bad797ec97cba038e37e007f343afa (diff)
downloadrails-18dba79bf27a370c823b34380120bff49cec08e2.tar.gz
rails-18dba79bf27a370c823b34380120bff49cec08e2.tar.bz2
rails-18dba79bf27a370c823b34380120bff49cec08e2.zip
Example of mobile configuration for system test in guide [ci skip]
Diffstat (limited to 'guides/source/testing.md')
-rw-r--r--guides/source/testing.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index e0a2d281d9..d9227f3c0a 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -778,6 +778,34 @@ send a POST request to create the new article in the database.
We will be redirected back to the the articles index page and there we assert
that the text from the new article's title is on the articles index page.
+#### Testing for multiple screen sizes
+If you want to test for mobile sizes on top of testing for desktop,
+you can create another class that inherits from SystemTestCase and use in your
+test suite. In this example a file called `mobile_system_test_case.rb` is created
+in the `/test` directory with the following configuration.
+
+```ruby
+require "test_helper"
+
+class MobileSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :chrome, screen_size: [375, 667]
+end
+```
+To use this configuration, create a test inside `test/system` that inherits from `MobileSystemTestCase`.
+Now you can test your app using multiple different configurations.
+
+```ruby
+require "mobile_system_test_case"
+
+class PostsTest < MobileSystemTestCase
+
+ test "visiting the index" do
+ visit posts_url
+ assert_selector "h1", text: "Posts"
+ end
+end
+```
+
#### Taking it further
The beauty of system testing is that it is similar to integration testing in