Module: Webrat::Matchers

Defined in:
lib/webrat/core/matchers/have_xpath.rb,
lib/webrat/core/matchers/have_content.rb,
lib/webrat/core/matchers/have_selector.rb

Defined Under Namespace

Classes: HasContent, HaveSelector, HaveXpath

Instance Method Summary (collapse)

Instance Method Details

- (Object) assert_contain(content)

Asserts that the body of the response contain the supplied string or regexp



55
56
57
58
# File 'lib/webrat/core/matchers/have_content.rb', line 55

def assert_contain(content)
  hc = HasContent.new(content)
  assert hc.matches?(response_body), hc.failure_message
end

- (Object) assert_have_no_selector(name, attributes = {}, &block)

Asserts that the body of the response does not contain the supplied string or regepx



68
69
70
71
# File 'lib/webrat/core/matchers/have_selector.rb', line 68

def assert_have_no_selector(name, attributes = {}, &block)
  matcher = HaveSelector.new(name, attributes, &block)
  assert !matcher.matches?(response_body), matcher.negative_failure_message
end

- (Object) assert_have_no_xpath(expected, options = {}, &block)



118
119
120
121
# File 'lib/webrat/core/matchers/have_xpath.rb', line 118

def assert_have_no_xpath(expected, options = {}, &block)
  hs = HaveXpath.new(expected, options, &block)
  assert !hs.matches?(response_body), hs.negative_failure_message
end

- (Object) assert_have_selector(name, attributes = {}, &block)

Asserts that the body of the response contains the supplied selector



61
62
63
64
# File 'lib/webrat/core/matchers/have_selector.rb', line 61

def assert_have_selector(name, attributes = {}, &block)
  matcher = HaveSelector.new(name, attributes, &block)
  assert matcher.matches?(response_body), matcher.failure_message
end

- (Object) assert_have_xpath(expected, options = {}, &block)



113
114
115
116
# File 'lib/webrat/core/matchers/have_xpath.rb', line 113

def assert_have_xpath(expected, options = {}, &block)
  hs = HaveXpath.new(expected, options, &block)
  assert hs.matches?(response_body), hs.failure_message
end

- (Object) assert_not_contain(content)

Asserts that the body of the response does not contain the supplied string or regepx



62
63
64
65
# File 'lib/webrat/core/matchers/have_content.rb', line 62

def assert_not_contain(content)
  hc = HasContent.new(content)
  assert !hc.matches?(response_body), hc.negative_failure_message
end

- (Object) contain(content)

Matches the contents of an HTML document with whatever string is supplied



49
50
51
# File 'lib/webrat/core/matchers/have_content.rb', line 49

def contain(content)
  HasContent.new(content)
end

- (Object) have_selector(name, attributes = {}, &block) Also known as: match_selector

Matches HTML content against a CSS 3 selector.

Parameters

expected<String>

The CSS selector to look for.

Returns

HaveSelector

A new have selector matcher.



53
54
55
# File 'lib/webrat/core/matchers/have_selector.rb', line 53

def have_selector(name, attributes = {}, &block)
  HaveSelector.new(name, attributes, &block)
end

- (Object) have_xpath(expected, options = {}, &block) Also known as: match_xpath

Matches HTML content against an XPath query

Parameters

expected<String>

The XPath query to look for.

Returns

HaveXpath

A new have xpath matcher.



108
109
110
# File 'lib/webrat/core/matchers/have_xpath.rb', line 108

def have_xpath(expected, options = {}, &block)
  HaveXpath.new(expected, options, &block)
end