diff options
Diffstat (limited to 'actionsystemtest')
-rw-r--r-- | actionsystemtest/README.md | 12 | ||||
-rw-r--r-- | actionsystemtest/lib/action_system_test.rb | 21 | ||||
-rw-r--r-- | actionsystemtest/lib/action_system_test/server.rb | 19 | ||||
-rw-r--r-- | actionsystemtest/test/cases/action_system_test_test.rb | 12 | ||||
-rw-r--r-- | actionsystemtest/test/cases/server_test.rb | 4 |
5 files changed, 22 insertions, 46 deletions
diff --git a/actionsystemtest/README.md b/actionsystemtest/README.md index 87f4001a8d..4238b9a749 100644 --- a/actionsystemtest/README.md +++ b/actionsystemtest/README.md @@ -57,7 +57,7 @@ The <tt>system_test_helper.rb</tt> file provides a home for all of your Capybara and Action System Test configuration. The default configuration uses the Selenium driver, with the Chrome browser, -served by Puma on port 21800 with a screen size of 1400x1400. +and a screen size of 1400x1400. Changing the configuration is as simple as changing the driver in your <tt>system_test_helper.rb</tt> @@ -67,17 +67,17 @@ you can change `driven_by` in the helper file. The driver name is a required argument for `driven_by`. The optional arguments that can be passed to `driven_by` are `:using` for the browser (this will only -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. +be used for non-headless drivers like Selenium), and `:screen_size` to change +the size of the screen for screenshots. Below are some examples for changing the default configuration settings for system tests: -Changing the browser, port for Puma, and screen size: +Changing the browser and screen size: ```ruby class ActionSystemTestCase < ActionSystemTest::Base - driven_by :selenium, using: :firefox, on: 3000, screen_size: [ 800, 800 ] + driven_by :selenium, using: :firefox, screen_size: [ 800, 800 ] end ``` @@ -86,7 +86,7 @@ using a headless driver simply leave out the `:using` argument. ```ruby class ActionSystemTestCase < ActionSystemTest::Base - driven_by :poltergeist, on: 3000 + driven_by :poltergeist end ``` diff --git a/actionsystemtest/lib/action_system_test.rb b/actionsystemtest/lib/action_system_test.rb index d28e30d116..3c96361725 100644 --- a/actionsystemtest/lib/action_system_test.rb +++ b/actionsystemtest/lib/action_system_test.rb @@ -71,16 +71,16 @@ module ActionSystemTest # :nodoc: # end # # By default, <tt>ActionSystemTest</tt> is driven by the Selenium driver, with - # the Chrome browser, on port 21800, and a browser size of 1400x1400. + # the Chrome browser, and a browser size of 1400x1400. # # Changing the driver configuration options are easy. Let's say you want to use - # port 3000, and the Firefox browser instead. In your +system_test_helper.rb+ + # and the Firefox browser instead. In your +system_test_helper.rb+ # file add the following: # # require "test_helper" # # class ActionSystemTestCase < ActionSystemTest::Base - # driven_by :selenium, using: :firefox, on: 3000 + # driven_by :selenium, using: :firefox # # teardown do # take_failed_screenshot @@ -90,8 +90,7 @@ module ActionSystemTest # :nodoc: # # +driven_by+ has a required argument for the driver name. The keyword # arguments are +:using+ for the browser (not applicable for headless drivers), - # +:on+ for port (the server is always Puma), and +:screen_size+ to change - # the size of the screen when taking screenshots. + # and +:screen_size+ to change the size of the screen taking screenshots. # # To use a headless driver, like Poltergeist, update your Gemfile to use # Poltergeist instead of Selenium and then declare the driver name in the @@ -129,17 +128,19 @@ module ActionSystemTest # :nodoc: # Action System Test configuration options # - # The defaults settings are Selenium, using Chrome, on port 21800, with a - # screen size of 1400x1400. + # The defaults settings are Selenium, using Chrome, with a screen size + # of 1400x1400. # # Examples: # # driven_by :poltergeist # - # driven_by :selenium, using: :firefox, on: 3000 - def self.driven_by(driver, using: :chrome, on: 21800, screen_size: [1400, 1400]) + # driven_by :selenium, using: :firefox + # + # driven_by :selenium, screen_size: [800, 800] + def self.driven_by(driver, using: :chrome, screen_size: [1400, 1400]) Driver.new(driver).run - Server.new(on).run + Server.new.run Browser.new(using, screen_size).run if selenium?(driver) end diff --git a/actionsystemtest/lib/action_system_test/server.rb b/actionsystemtest/lib/action_system_test/server.rb index 6f87b2767d..76ae30f753 100644 --- a/actionsystemtest/lib/action_system_test/server.rb +++ b/actionsystemtest/lib/action_system_test/server.rb @@ -2,10 +2,6 @@ require "rack/handler/puma" module ActionSystemTest class Server # :nodoc: - def initialize(port) - @port = port - end - def run register setup @@ -13,22 +9,13 @@ module ActionSystemTest private def register - Capybara.register_server :puma do |app, host| - Rack::Handler::Puma.run(app, Port: @port, Threads: "0:1") + Capybara.register_server :rails_puma do |app, port, host| + Rack::Handler::Puma.run(app, Port: port, Threads: "0:1") end end def setup - set_server - set_port - end - - def set_server - Capybara.server = :puma - end - - def set_port - Capybara.server_port = @port + Capybara.server = :rails_puma end end end diff --git a/actionsystemtest/test/cases/action_system_test_test.rb b/actionsystemtest/test/cases/action_system_test_test.rb index 732c06ba20..b77da5a5a9 100644 --- a/actionsystemtest/test/cases/action_system_test_test.rb +++ b/actionsystemtest/test/cases/action_system_test_test.rb @@ -8,18 +8,6 @@ class ActionSystemTestTest < ActiveSupport::TestCase assert_equal :poltergeist, Capybara.default_driver end - test "driven_by defaults to port 21800" do - ActionSystemTest::Base.driven_by :poltergeist - - assert_equal 21800, Capybara.server_port - end - - test "driven_by can change Capybara's server port" do - ActionSystemTest::Base.driven_by :selenium, on: 3000 - - assert_equal 3000, Capybara.server_port - end - test "driven_by sets Capybara's drivers respectively" do ActionSystemTest::Base.driven_by :selenium, using: :chrome diff --git a/actionsystemtest/test/cases/server_test.rb b/actionsystemtest/test/cases/server_test.rb index 39a9be5026..627b146d03 100644 --- a/actionsystemtest/test/cases/server_test.rb +++ b/actionsystemtest/test/cases/server_test.rb @@ -3,7 +3,7 @@ require "action_system_test" class ServerTest < ActiveSupport::TestCase test "initializing the server port" do - server = ActionSystemTest::Server.new(21800) - assert_equal 21800, server.instance_variable_get(:@port) + server = ActionSystemTest::Server + assert_includes Capybara.servers, :rails_puma end end |