Module: Merb::Test::Rspec::ViewMatchers

Defined in:
lib/merb-core/test/matchers/view_matchers.rb

Defined Under Namespace

Classes: HasTag, HaveSelector, MatchTag, NotMatchTag

Instance Method Summary collapse

Instance Method Details

#have_selector(expected) ⇒ Object Also known as: match_selector

Parameters

expected<String>

The string to look for.

Returns

HaveSelector

A new have selector matcher.



262
263
264
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 262

def have_selector(expected)
  HaveSelector.new(expected)
end

#have_tag(tag, attributes = {}) ⇒ 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)


288
289
290
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 288

def have_tag(tag, attributes = {})
  HasTag.new(tag, attributes)
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.



244
245
246
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 244

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.



253
254
255
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 253

def not_match_tag(attrs)
  NotMatchTag.new(attrs)
end