diff options
Diffstat (limited to 'actionpack/test/system_testing')
3 files changed, 103 insertions, 0 deletions
diff --git a/actionpack/test/system_testing/capybara_rack_test_driver_test.rb b/actionpack/test/system_testing/capybara_rack_test_driver_test.rb new file mode 100644 index 0000000000..0f037760d3 --- /dev/null +++ b/actionpack/test/system_testing/capybara_rack_test_driver_test.rb @@ -0,0 +1,26 @@ +require 'abstract_unit' + +class CapybaraRackTestDriverTest < ActiveSupport::TestCase + def test_default_driver_adapter + assert_kind_of SystemTesting::DriverAdapters::CapybaraRackTestDriver, Rails::SystemTestCase.driver + end + + def test_default_settings + assert_equal 'Capybara', Rails::SystemTestCase.driver.useragent + end + + def test_setting_useragent + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraRackTestDriver.new( + useragent: 'x' + ) + assert_equal 'x', Rails::SystemTestCase.driver.useragent + end + + def test_does_not_accept_nonsense_kwargs + assert_raises ArgumentError do + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraRackTestDriver.new( + made_up_arg: 'x' + ) + end + end +end diff --git a/actionpack/test/system_testing/capybara_selenium_driver_test.rb b/actionpack/test/system_testing/capybara_selenium_driver_test.rb new file mode 100644 index 0000000000..6357b35aa6 --- /dev/null +++ b/actionpack/test/system_testing/capybara_selenium_driver_test.rb @@ -0,0 +1,58 @@ +require 'abstract_unit' + +class CapybaraSeleniumDriverTest < ActiveSupport::TestCase + def setup + Rails::SystemTestCase.driver = :capybara_selenium_driver + end + + def test_setting_driver_adapter_to_selenium + assert_kind_of SystemTesting::DriverAdapters::CapybaraSeleniumDriver, Rails::SystemTestCase.driver + end + + def test_default_settings + assert_equal :chrome, Rails::SystemTestCase.driver.browser + assert_equal :puma, Rails::SystemTestCase.driver.server + assert_equal 28100, Rails::SystemTestCase.driver.port + assert_equal [1400,1400], Rails::SystemTestCase.driver.screen_size + end + + def test_setting_browser + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new( + browser: :firefox + ) + + assert_equal :firefox, Rails::SystemTestCase.driver.browser + end + + def test_setting_server + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new( + server: :webrick + ) + + assert_equal :webrick, Rails::SystemTestCase.driver.server + end + + def test_setting_port + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new( + port: 3000 + ) + + assert_equal 3000, Rails::SystemTestCase.driver.port + end + + def test_setting_screen_size + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new( + screen_size: [ 800, 800 ] + ) + + assert_equal [ 800, 800 ], Rails::SystemTestCase.driver.screen_size + end + + def test_does_not_accept_nonsense_kwargs + assert_raises ArgumentError do + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraSeleniumDriver.new( + made_up_arg: 'x' + ) + end + end +end diff --git a/actionpack/test/system_testing/driver_adapter_test.rb b/actionpack/test/system_testing/driver_adapter_test.rb new file mode 100644 index 0000000000..bfbeaa63a2 --- /dev/null +++ b/actionpack/test/system_testing/driver_adapter_test.rb @@ -0,0 +1,19 @@ +require 'abstract_unit' + +class DriverAdapterTest < ActiveSupport::TestCase + test 'only registered adapters are accepted' do + assert_raises(NameError) do + Rails::SystemTestCase.driver = :whatever + end + + assert_nothing_raised do + Rails::SystemTestCase.driver = :capybara_selenium_driver + end + end + + test 'settings can only be used for the appropriate adapter' do + assert_raises(ArgumentError) do + Rails::SystemTestCase.driver = SystemTesting::DriverAdapters::CapybaraRackTestDriver.new(something: 'test') + end + end +end |