Module: Locator::Assertions

Includes:
Matcher, Test::Unit::Assertions
Defined in:
lib/locator/assertions.rb

Instance Method Summary collapse

Methods included from Matcher

#contain, #have_css, #have_css_class, #have_tag, #have_xpath

Instance Method Details

#assert_contains(*args) ⇒ Object

Asserts that the response body contains the given string or regexp



8
9
10
11
# File 'lib/locator/assertions.rb', line 8

def assert_contains(*args)
  matcher = contain(*args)
  assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
end

#assert_css_class(css_classes, css_class) ⇒ Object



56
57
58
59
# File 'lib/locator/assertions.rb', line 56

def assert_css_class(css_classes, css_class)
  matcher = HaveCssClass.new(css_class)
  assert matcher.matches?(css_classes.body), matcher.failure_message
end

#assert_does_not_contain(*args) ⇒ Object

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



14
15
16
17
# File 'lib/locator/assertions.rb', line 14

def assert_does_not_contain(*args)
  matcher = contain(*args)
  assert !matcher.matches?(send(__response_accessor).body), matcher.negative_failure_message
end

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

Asserts that the response body matches the given CSS selector



44
45
46
47
# File 'lib/locator/assertions.rb', line 44

def assert_has_css(html, *args, &block)
  matcher = have_css(*args, &block)
  assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
end

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



19
20
21
22
# File 'lib/locator/assertions.rb', line 19

def assert_has_tag(html, *args, &block)
  matcher = have_tag(*args, &block)
  assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
end

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

Asserts that the response body matches the given XPath



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

def assert_has_xpath(html, *args, &block)
  matcher = have_xpath(*args, &block)
  assert matcher.matches?(send(__response_accessor).body), matcher.failure_message
end

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

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



50
51
52
53
# File 'lib/locator/assertions.rb', line 50

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

#assert_no_css_class(css_classes, css_class) ⇒ Object



61
62
63
64
# File 'lib/locator/assertions.rb', line 61

def assert_no_css_class(css_classes, css_class)
  matcher = HaveCssClass.new(css_class)
  assert matcher.matches?(css_classes.body), matcher.negative_failure_message
end

#assert_no_tag(html, *args, &block) ⇒ Object Also known as: assert_does_not_have_tag, assert_does_not_have_xpath, assert_does_not_have_css, assert_does_not_include_css_class



24
25
26
27
# File 'lib/locator/assertions.rb', line 24

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

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

Asserts that the response body does not match the given XPath



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

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