Class: RSpec::TagMatchers::HasForm
- Defined in:
- lib/rspec/tag_matchers/has_form.rb
Overview
A matcher that matches <form> tags.
Instance Method Summary collapse
-
#initialize ⇒ HasForm
constructor
Initializes a HasForm matcher that matches
form
elements. -
#with_action(action) ⇒ HasForm
Specifies that the form must target the given URL as its action.
-
#with_verb(verb) ⇒ HasForm
(also: #with_method)
Specifies that the form will use the given HTTP verb, following Rails conventions.
Methods inherited from HasTag
#description, #failure_message, #matches?, #negative_failure_message, #test_attribute, #with_attribute, #with_content, #with_count, #with_criteria
Methods included from RSpec::TagMatchers::Helpers::SentenceHelper
Constructor Details
#initialize ⇒ HasForm
Initializes a HasForm matcher that matches form
elements.
28 29 30 |
# File 'lib/rspec/tag_matchers/has_form.rb', line 28 def initialize super(:form) end |
Instance Method Details
#with_action(action) ⇒ HasForm
Specifies that the form must target the given URL as its action. It compares the action
attribute on the form
tag to the action
argument passed to with_action
.
53 54 55 |
# File 'lib/rspec/tag_matchers/has_form.rb', line 53 def with_action(action) with_attribute(:action => action) end |
#with_verb(verb) ⇒ HasForm Also known as: with_method
Specifies that the form will use the given HTTP verb, following Rails conventions. It first looks for a method override value (a hidden input named _method
). If the method override value doesn’t exist, then it looks for the method
attribute on the form
tag. Whichever value it finds will be compared to the value passed in as the verb
argument to with_verb
.
40 41 42 43 44 |
# File 'lib/rspec/tag_matchers/has_form.rb', line 40 def with_verb(verb) with_criteria do |element| matches_verb?(element, verb) end end |