Module: Locator::Matcher

Defined in:
lib/locator/matcher.rb,
lib/locator/matcher/have_tag.rb

Defined Under Namespace

Classes: HaveTag

Instance Method Summary collapse

Instance Method Details

#assert_contain(*args) ⇒ Object

Asserts that the response body contains the given string or regexp



11
12
13
14
# File 'lib/locator/matcher.rb', line 11

def assert_contain(*args)
  matcher = contain(*args)
  assert matcher.matches?(response.body), matcher.failure_message
end

#assert_have_css(html, *args, &block) ⇒ Object

Asserts that the response body matches the given CSS selector



59
60
61
62
# File 'lib/locator/matcher.rb', line 59

def assert_have_css(html, *args, &block)
  matcher = have_css(*args, &block)
  assert matcher.matches?(response.body), matcher.failure_message
end

#assert_have_no_css(html, *args, &block) ⇒ Object

Asserts that the response body does not match the given CSS selector



65
66
67
68
# File 'lib/locator/matcher.rb', line 65

def assert_have_no_css(html, *args, &block)
  matcher = have_css(*args, &block)
  assert !matcher.matches?(response.body), matcher.negative_failure_message
end

#assert_have_no_tag(html, *args, &block) ⇒ Object



31
32
33
34
# File 'lib/locator/matcher.rb', line 31

def assert_have_no_tag(html, *args, &block)
  matcher = have_tag(*args, &block)
  assert !matcher.matches?(response.body), matcher.negative_failure_message
end

#assert_have_no_xpath(html, *args, &block) ⇒ Object

Asserts that the response body does not match the given XPath



48
49
50
51
# File 'lib/locator/matcher.rb', line 48

def assert_have_no_xpath(html, *args, &block)
  matcher = have_xpath(*args, &block)
  assert !matcher.matches?(response.body), matcher.negative_failure_message
end

#assert_have_tag(html, *args, &block) ⇒ Object



26
27
28
29
# File 'lib/locator/matcher.rb', line 26

def assert_have_tag(html, *args, &block)
  matcher = have_tag(*args, &block)
  assert matcher.matches?(response.body), matcher.failure_message
end

#assert_have_xpath(html, *args, &block) ⇒ Object

Asserts that the response body matches the given XPath



42
43
44
45
# File 'lib/locator/matcher.rb', line 42

def assert_have_xpath(html, *args, &block)
  matcher = have_xpath(*args, &block)
  assert matcher.matches?(response.body), matcher.failure_message
end

#assert_not_contain(*args) ⇒ Object

Asserts that the response body does not contain the given string or regexp



17
18
19
20
# File 'lib/locator/matcher.rb', line 17

def assert_not_contain(*args)
  matcher = contain(*args)
  assert !matcher.matches?(response.body), matcher.negative_failure_message
end

#contain(*args) ⇒ Object

Matches an HTML document with whatever string is given



6
7
8
# File 'lib/locator/matcher.rb', line 6

def contain(*args)
  HaveTag.new(*args)
end

#have_css(css, options = {}, &block) ⇒ Object

Matches HTML content against a CSS selector.



54
55
56
# File 'lib/locator/matcher.rb', line 54

def have_css(css, options = {}, &block)
  HaveTag.new(options.delete(:content), options.merge(:css => css), &block)
end

#have_tag(*args, &block) ⇒ Object



22
23
24
# File 'lib/locator/matcher.rb', line 22

def have_tag(*args, &block)
  HaveTag.new(*args, &block)
end

#have_xpath(xpath, options = {}, &block) ⇒ Object

Matches HTML content against an XPath



37
38
39
# File 'lib/locator/matcher.rb', line 37

def have_xpath(xpath, options = {}, &block)
  HaveTag.new(options.delete(:content), options.merge(:xpath => xpath), &block)
end