Class: RSpec::TagMatchers::HasForm

Inherits:
HasTag
  • Object
show all
Defined in:
lib/rspec/tag_matchers/has_form.rb

Overview

A matcher that matches <form> tags.

Instance Method Summary (collapse)

Methods inherited from HasTag

#description, #failure_message, #matches?, #negative_failure_message, #with_attribute, #with_content, #with_count, #with_criteria

Methods included from RSpec::TagMatchers::Helpers::SentenceHelper

#make_sentence

Constructor Details

- (HasForm) initialize

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

- (HasForm) with_action(action)

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

- (HasForm) with_verb(verb) 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