Skip to content

Commit

Permalink
Amend documentation
Browse files Browse the repository at this point in the history
Many changes have been made since the beginning so documentation needed
a refresher.
  • Loading branch information
eileencodes committed Feb 20, 2017
1 parent 84f82f0 commit 4540ceb
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
10 changes: 6 additions & 4 deletions actionsystemtest/lib/action_system_test/driver_adapter.rb
Expand Up @@ -2,22 +2,24 @@


module ActionSystemTest module ActionSystemTest
# The <tt>ActionSystemTest::DriverAdapter</tt> module is used to load the driver # The <tt>ActionSystemTest::DriverAdapter</tt> module is used to load the driver
# set in your Rails' test configuration file. # set in the +system_test_helper+ file generated with your application.
# #
# The default driver adapter is the +:rails_selenium_driver+. # The default driver adapter is the +:rails_selenium_driver+.
module DriverAdapter module DriverAdapter
extend ActiveSupport::Concern extend ActiveSupport::Concern


module ClassMethods module ClassMethods
# Returns the current driver that is set. If no driver is set in the # Returns the current driver that is set in the <tt>ActionSystemTestCase</tt>
# Rails' configuration file then +:rails_selenium_driver+ will be # class generated with your Rails application. If no driver is set
# initialized. # +:rails_selenium_driver+ will be initialized.
def driver def driver
@driver ||= DriverAdapters.lookup(DEFAULT_DRIVER) @driver ||= DriverAdapters.lookup(DEFAULT_DRIVER)
end end


# Specify the adapter and settings for the system test driver set in the # Specify the adapter and settings for the system test driver set in the
# Rails' configuration file. # Rails' configuration file.
#
# When set, the driver will be initialized.
def driver=(driver) def driver=(driver)
@driver = DriverAdapters.lookup(driver) @driver = DriverAdapters.lookup(driver)
@driver.call @driver.call
Expand Down
6 changes: 3 additions & 3 deletions actionsystemtest/lib/action_system_test/driver_adapters.rb
@@ -1,5 +1,5 @@
module ActionSystemTest module ActionSystemTest
# == System Testing Driver Adapters # == Action System Testing Driver Adapters
# #
# By default Rails supports Capybara with the Selenium Driver. Rails provides # By default Rails supports Capybara with the Selenium Driver. Rails provides
# configuration setup for using the selenium driver with Capybara. # configuration setup for using the selenium driver with Capybara.
Expand All @@ -14,7 +14,7 @@ module ActionSystemTest
# === Driver Features # === Driver Features
# #
# | | Default Browser | Supports Screenshots? | # | | Default Browser | Supports Screenshots? |
# |-----------------|-----------------------|-----------------------| # | --------------- | --------------------- | --------------------- |
# | Rails' Selenium | Chrome | Yes | # | Rails' Selenium | Chrome | Yes |
# | Rack Test | No JS Support | No | # | Rack Test | No JS Support | No |
# | Selenium | Firefox | Yes | # | Selenium | Firefox | Yes |
Expand All @@ -27,7 +27,7 @@ module DriverAdapters
autoload :RailsSeleniumDriver autoload :RailsSeleniumDriver


class << self class << self
# Returns driver for specified name. # Returns driver class for specified name.
# #
# ActionSystemTest::DriverAdapters.lookup(:rails_selenium_driver) # ActionSystemTest::DriverAdapters.lookup(:rails_selenium_driver)
# # => ActionSystemTest::DriverAdapters::RailsSeleniumDriver # # => ActionSystemTest::DriverAdapters::RailsSeleniumDriver
Expand Down
Expand Up @@ -4,8 +4,7 @@ module ActionSystemTest
module DriverAdapters module DriverAdapters
# == CapybaraDriver for System Testing # == CapybaraDriver for System Testing
# #
# The <tt>CapybaraDriver</tt> is a shim that sits between Rails and # The <tt>CapybaraDriver</tt> is a shim between Rails and Capybara.
# Capybara.
# #
# The drivers Capybara supports are: +:rack_test+, +:selenium+, +:webkit+, # The drivers Capybara supports are: +:rack_test+, +:selenium+, +:webkit+,
# and +:poltergeist+. # and +:poltergeist+.
Expand All @@ -15,16 +14,21 @@ module DriverAdapters
# directly. # directly.
# #
# To set your system tests to use one of Capybara's default drivers, add # To set your system tests to use one of Capybara's default drivers, add
# the following to yur Rails' configuration test environment: # the following to your +system_test_helper+ class file:
# #
# config.system_testing.driver = :rack_test # class ActionSystemTestCase < ActionSystemTest::Base
# ActionSystemTest.driver = :rack_test
# end
# #
# The +:rack_test+ driver is a basic test driver that doesn't support # The +:rack_test+ driver is a basic test driver that doesn't support
# JavaScript testing and doesn't require a server. # JavaScript testing and doesn't require a server.
# #
# The +:poltergeist+ and +:webkit+ drivers are headless, but require some # The +:poltergeist+ and +:webkit+ drivers are headless, but require some
# extra environment setup. Because the default server for Rails is Puma, each # extra environment setup. Please see their README's for instructions on
# of the Capybara drivers will default to using Puma. Changing the configuration # environment setup.
#
# Because the default server for Rails is Puma, each of the Capybara
# drivers will default to using Puma. Changing the configuration
# to use Webrick is possible by initalizing a new driver object. # to use Webrick is possible by initalizing a new driver object.
# #
# The default settings for the <tt>CapybaraDriver</tt> are: # The default settings for the <tt>CapybaraDriver</tt> are:
Expand All @@ -35,10 +39,10 @@ module DriverAdapters
# @port=28100 # @port=28100
# > # >
# #
# The settings for the <tt>CapybaraDriver</tt> can be changed from # The settings for the <tt>CapybaraDriver</tt> can be changed in the
# Rails' configuration file. # +system_test_helper+ file in your application's test directory.
# #
# config.system_testing.driver = ActionSystemTest::DriverAdapters::CapybaraDriver.new( # ActionSystemTest.driver = ActionSystemTest::DriverAdapters::CapybaraDriver.new(
# name: :webkit, # name: :webkit,
# server: :webrick # server: :webrick
# ) # )
Expand Down
Expand Up @@ -2,7 +2,7 @@


module ActionSystemTest module ActionSystemTest
module DriverAdapters module DriverAdapters
# == RailsSeleniumDriver for System Testing # == RailsSeleniumDriver for Action System Test
# #
# The <tt>RailsSeleniumDriver</tt> uses the Selenium 2.0 webdriver. The # The <tt>RailsSeleniumDriver</tt> uses the Selenium 2.0 webdriver. The
# selenium-webdriver gem is required by this driver. # selenium-webdriver gem is required by this driver.
Expand All @@ -12,9 +12,11 @@ module DriverAdapters
# #
# By default Rails system testing will use Rails' configuration with Capybara # By default Rails system testing will use Rails' configuration with Capybara
# and the Selenium driver. To explictly set the <tt>RailsSeleniumDriver</tt> # and the Selenium driver. To explictly set the <tt>RailsSeleniumDriver</tt>
# add the following to your Rails' configuration test environment: # add the following to your +system_test_helper+:
# #
# config.system_testing.driver = :rails_selenium_driver # class ActionSystemTest < ActionSystemTest::Base
# ActionSystemTest.driver = :rails_selenium_driver
# end
# #
# Because this driver supports real browser testing it is required that a # Because this driver supports real browser testing it is required that a
# server is configured. # server is configured.
Expand All @@ -31,24 +33,27 @@ module DriverAdapters
# > # >
# #
# The settings for the <tt>RailsSeleniumDriver</tt> can be changed in the # The settings for the <tt>RailsSeleniumDriver</tt> can be changed in the
# Rails configuration file. # +system_test_helper+.
# #
# config.system_testing.driver = ActionSystemTest::DriverAdapters::RailsSeleniumDriver.new( # class ActionSystemTest < ActionSystemTest::Base
# server: :webrick, # ActionSystemTest.driver = ActionSystemTest::DriverAdapters::RailsSeleniumDriver.new(
# port: 28100, # server: :webrick,
# screen_size: [ 800, 800 ] # port: 28100,
# ) # screen_size: [ 800, 800 ]
# )
# end
# #
# The default browser is set to Chrome because the current version of # The default browser is set to Chrome. If you want to use Firefox,
# Firefox does not work with selenium-webdriver. If you want to use Firefox,
# you will need to use Firefox 45.0esr or 47.0 and ensure # you will need to use Firefox 45.0esr or 47.0 and ensure
# that selenium-webdriver is version 2.53.4. To change the browser from # that selenium-webdriver is version 2.53.4. To change the browser from
# +:chrome+ to +:firefox+, initialize the Selenium driver in your Rails' # +:chrome+ to +:firefox+, initialize the Selenium driver in your Rails'
# test environment: # test environment:
# #
# config.system_testing.driver = ActionSystemTest::DriverAdapters::RailsSeleniumDriver.new( # class ActionSystemTest < ActionSystemTest::Base
# browser: :firefox # ActionSystemTest.driver = ActionSystemTest::DriverAdapters::RailsSeleniumDriver.new(
# ) # browser: :firefox
# )
# end
class RailsSeleniumDriver class RailsSeleniumDriver
include WebServer include WebServer


Expand Down
Expand Up @@ -2,14 +2,13 @@ module ActionSystemTest
module TestHelpers module TestHelpers
# Screenshot helper for system testing # Screenshot helper for system testing
module ScreenshotHelper module ScreenshotHelper
# Takes a screenshot of the current page in the browser if the system # Takes a screenshot of the current page in the browser.
# test driver supports screenshots and the test failed.
# #
# Additionally +take_screenshot+ can be used within your tests at points # +take_screenshot+ can be used within your tests at points
# you want to take a screenshot if the driver supports screenshots. The # you want to take a screenshot if the driver supports screenshots. The
# Rack Test driver does not support screenshots. # Rack Test driver does not support screenshots.
# #
# You can check of the driver supports screenshots by running # You can check if the driver supports screenshots by running
# #
# ActionSystemTest.driver.supports_screenshots? # ActionSystemTest.driver.supports_screenshots?
# => true # => true
Expand All @@ -18,6 +17,8 @@ def take_screenshot
puts find_image puts find_image
end end


# Takes a screenshot only if the test failed. This is included
# by default in +teardown+ of system test.
def take_failed_screenshot def take_failed_screenshot
take_screenshot unless passed? take_screenshot unless passed?
end end
Expand Down

0 comments on commit 4540ceb

Please sign in to comment.