aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/system_testing/test_helper.rb2
-rw-r--r--actionpack/lib/system_testing/test_helpers.rb7
-rw-r--r--actionpack/lib/system_testing/test_helpers/form_helper.rb30
3 files changed, 39 insertions, 0 deletions
diff --git a/actionpack/lib/system_testing/test_helper.rb b/actionpack/lib/system_testing/test_helper.rb
index 68b187ed7a..9ac2e02f01 100644
--- a/actionpack/lib/system_testing/test_helper.rb
+++ b/actionpack/lib/system_testing/test_helper.rb
@@ -1,8 +1,10 @@
require 'capybara/rails'
+require 'system_testing/test_helpers'
module SystemTesting
module TestHelper
include Capybara::DSL
+ include TestHelpers::FormHelper
def after_teardown
Capybara.reset_sessions!
diff --git a/actionpack/lib/system_testing/test_helpers.rb b/actionpack/lib/system_testing/test_helpers.rb
new file mode 100644
index 0000000000..add9596463
--- /dev/null
+++ b/actionpack/lib/system_testing/test_helpers.rb
@@ -0,0 +1,7 @@
+module SystemTesting
+ module TestHelpers
+ extend ActiveSupport::Autoload
+
+ autoload :FormHelper
+ end
+end
diff --git a/actionpack/lib/system_testing/test_helpers/form_helper.rb b/actionpack/lib/system_testing/test_helpers/form_helper.rb
new file mode 100644
index 0000000000..6ce5c54864
--- /dev/null
+++ b/actionpack/lib/system_testing/test_helpers/form_helper.rb
@@ -0,0 +1,30 @@
+module SystemTesting
+ module TestHelpers
+ module FormHelper
+ def fill_in_all_fields(fields)
+ fields.each do |name, value|
+ fill_in name, with: value
+ end
+ end
+
+ def click_checkbox_label(name, checked: false)
+ field = find_checkbox(name, checked)
+ label = find_label_wrapper(field)
+ label.click
+ end
+
+ def press_enter
+ page.driver.browser.action.send_keys(:enter).perform
+ end
+
+ private
+ def find_checkbox(name, checked)
+ find(:field, name, visible: :all, checked: checked)
+ end
+
+ def find_label_wrapper(field, location: './ancestor::label')
+ field.find :xpath, location
+ end
+ end
+ end
+end