Skip to content

Commit 8c3495b

Browse files
committed
add matcher #have_submit_input
1 parent 8e353f4 commit 8c3495b

File tree

1 file changed

+16
-0
lines changed
  • lib/capybara/active_admin/matchers

1 file changed

+16
-0
lines changed

lib/capybara/active_admin/matchers/form.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ def have_has_many_fields_for(association_name, options = {})
3232
selector = has_many_fields_selector(association_name)
3333
have_selector(selector, options)
3434
end
35+
36+
# @param text [String] button title
37+
# @param options [Hash]
38+
# @option selector [String, nil] optional selector to append
39+
# @option disabled [Boolean] button disabled or not (default false)
40+
# @example
41+
# expect(page).to have_submit_input('Submit') # check that submit input is present
42+
# expect(page).to have_submit_input('Submit', selector: '.custom-class') # check custom class presence
43+
# expect(page).to have_submit_input('Submit', disabled: true) # check that submit input is disabled
44+
# expect(page).to have_submit_input('Submit', disabled: true, count: 0) # check that submit input is enabled
45+
#
46+
def have_submit_input(text, options = {})
47+
selector = "#{form_submit_selector(text)}#{options.delete(:selector)}"
48+
selector += '[disabled="disabled"].disabled' if options.delete(:disabled)
49+
have_selector(selector, options)
50+
end
3551
end
3652
end
3753
end

0 commit comments

Comments
 (0)