diff options
author | eileencodes <eileencodes@gmail.com> | 2016-08-12 08:19:55 -0400 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2017-02-20 15:07:31 -0500 |
commit | 93eff636a677215eb130f775b99e9421fb30f7a2 (patch) | |
tree | 3652b95d82adc57287c093177d24a95624da9673 | |
parent | 0dc63281da1c7075ce63d8dba62e4230d72bfc2a (diff) | |
download | rails-93eff636a677215eb130f775b99e9421fb30f7a2.tar.gz rails-93eff636a677215eb130f775b99e9421fb30f7a2.tar.bz2 rails-93eff636a677215eb130f775b99e9421fb30f7a2.zip |
Add test assertion helpers
Adds assertions that are not part of Capybara but may be useful to Rails
users writing system tests.
-rw-r--r-- | actionpack/lib/system_testing/test_helper.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/system_testing/test_helpers.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/system_testing/test_helpers/assertions.rb | 32 |
3 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/lib/system_testing/test_helper.rb b/actionpack/lib/system_testing/test_helper.rb index 9ac2e02f01..bb68cfe665 100644 --- a/actionpack/lib/system_testing/test_helper.rb +++ b/actionpack/lib/system_testing/test_helper.rb @@ -5,6 +5,7 @@ module SystemTesting module TestHelper include Capybara::DSL include TestHelpers::FormHelper + include TestHelpers::Assertions def after_teardown Capybara.reset_sessions! diff --git a/actionpack/lib/system_testing/test_helpers.rb b/actionpack/lib/system_testing/test_helpers.rb index add9596463..074a45d5c8 100644 --- a/actionpack/lib/system_testing/test_helpers.rb +++ b/actionpack/lib/system_testing/test_helpers.rb @@ -3,5 +3,6 @@ module SystemTesting extend ActiveSupport::Autoload autoload :FormHelper + autoload :Assertions end end diff --git a/actionpack/lib/system_testing/test_helpers/assertions.rb b/actionpack/lib/system_testing/test_helpers/assertions.rb new file mode 100644 index 0000000000..865b5e59db --- /dev/null +++ b/actionpack/lib/system_testing/test_helpers/assertions.rb @@ -0,0 +1,32 @@ +module SystemTesting + module TestHelpers + module Assertions + def assert_all_of_selectors(*items) + options = items.extract_options! + type = type_for_selector(items) + + items.each do |item| + assert_selector type, item, options + end + end + + def assert_none_of_selectors(*items) + options = items.extract_options! + type = type_for_selector(items) + + items.each do |item| + assert_no_selector type, item, options + end + end + + private + def type_for_selector(*items) + if items.first.is_a?(Symbol) + items.shift + else + Capybara.default_selector + end + end + end + end +end |