Module: Merb::Test::Rspec::ViewMatchers
- Defined in:
- lib/merb-core/test/matchers/view_matchers.rb
Defined Under Namespace
Classes: HasContent, HasTag, HaveSelector, MatchTag, NotMatchTag
Instance Method Summary collapse
- #contain(content) ⇒ Object
-
#have_selector(expected) ⇒ Object
(also: #match_selector)
Parameters expected<String>:: The string to look for.
-
#have_tag(tag, attributes = {}, &blk) ⇒ Object
(also: #with_tag)
RSpec matcher to test for the presence of tags.
-
#match_tag(name, attrs = {}) ⇒ Object
Parameters name<~to_s>:: The name of the tag to look for.
-
#not_match_tag(attrs) ⇒ Object
Parameters attrs<Hash>:: A set of attributes that must not be matched.
Instance Method Details
#contain(content) ⇒ Object
332 333 334 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 332 def contain(content) HasContent.new(content) end |
#have_selector(expected) ⇒ Object Also known as: match_selector
Parameters
- expected<String>
-
The string to look for.
Returns
- HaveSelector
-
A new have selector matcher.
300 301 302 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 300 def have_selector(expected) HaveSelector.new(expected) end |
#have_tag(tag, attributes = {}, &blk) ⇒ Object Also known as: with_tag
RSpec matcher to test for the presence of tags.
Parameters
- tag<~to_s>
-
The name of the tag.
- attributes<Hash>
-
Tag attributes.
Returns
- HasTag
-
A new has tag matcher.
Examples
# Check for <div>
body.should have_tag("div")
# Check for <span id="notice">
body.should have_tag("span", :id => :notice)
# Check for <h1 id="foo" class="bar">
body.should have_tag(:h2, :class => "bar", :id => "foo")
# Check for <div attr="val">
body.should have_tag(:div, :attr => :val)
326 327 328 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 326 def have_tag(tag, attributes = {}, &blk) HasTag.new(tag, attributes, &blk) end |
#match_tag(name, attrs = {}) ⇒ Object
Parameters
- name<~to_s>
-
The name of the tag to look for.
- attrs<Hash>
-
Attributes to look for in the tag (see below).
Options (attrs)
- :content<String>
-
Optional content to match.
Returns
- MatchTag
-
A new match tag matcher.
282 283 284 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 282 def match_tag(name, attrs={}) MatchTag.new(name, attrs) end |
#not_match_tag(attrs) ⇒ Object
Parameters
- attrs<Hash>
-
A set of attributes that must not be matched.
Returns
- NotMatchTag
-
A new not match tag matcher.
291 292 293 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 291 def not_match_tag(attrs) NotMatchTag.new(attrs) end |