aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/system_testing
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-01 07:54:28 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-04 17:40:51 +0900
commit2ee4058cc5c9327ddc5bfecc05e625320dd166a1 (patch)
tree9402f72c7c4e0e3da64fbb397b0f0aca06f0b1f9 /actionpack/test/dispatch/system_testing
parentde17d9e23d2dd7ea4551919a56031221f10f07bd (diff)
downloadrails-2ee4058cc5c9327ddc5bfecc05e625320dd166a1.tar.gz
rails-2ee4058cc5c9327ddc5bfecc05e625320dd166a1.tar.bz2
rails-2ee4058cc5c9327ddc5bfecc05e625320dd166a1.zip
Do not take screenshot if driver does not support screenshot
`Capybara::RackTest::Driver` does not support taking screenshots. If call `#save_screenshot` on `Capybara::RackTest::Driver` will raise the error. ```ruby Error: UsersTest#test_visiting_the_index: Capybara::NotSupportedByDriverError: Capybara::Driver::Base#save_screenshot ``` To prevent errors, if driver does not support screenshot, do not call it.
Diffstat (limited to 'actionpack/test/dispatch/system_testing')
-rw-r--r--actionpack/test/dispatch/system_testing/screenshot_helper_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
index 3b4ea96c4f..d6b501b3ac 100644
--- a/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
+++ b/actionpack/test/dispatch/system_testing/screenshot_helper_test.rb
@@ -1,5 +1,6 @@
require "abstract_unit"
require "action_dispatch/system_testing/test_helpers/screenshot_helper"
+require "capybara/dsl"
class ScreenshotHelperTest < ActiveSupport::TestCase
test "image path is saved in tmp directory" do
@@ -25,4 +26,28 @@ class ScreenshotHelperTest < ActiveSupport::TestCase
end
end
end
+
+ test "rack_test driver does not support screenshot" do
+ begin
+ original_driver = Capybara.current_driver
+ Capybara.current_driver = :rack_test
+
+ new_test = ActionDispatch::SystemTestCase.new("x")
+ assert_not new_test.send(:supports_screenshot?)
+ ensure
+ Capybara.current_driver = original_driver
+ end
+ end
+
+ test "selenium driver supports screenshot" do
+ begin
+ original_driver = Capybara.current_driver
+ Capybara.current_driver = :selenium
+
+ new_test = ActionDispatch::SystemTestCase.new("x")
+ assert new_test.send(:supports_screenshot?)
+ ensure
+ Capybara.current_driver = original_driver
+ end
+ end
end