Class: RSpecXML::XMLMatchers::HaveXPath

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-xml/xml_matchers/have_xpath.rb,
lib/rspec-xml/xml_matchers/have_xpath/matcher.rb,
lib/rspec-xml/xml_matchers/have_xpath/attr_matcher.rb,
lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb

Defined Under Namespace

Classes: AttrMatcher, Matcher, TextMatcher

Instance Method Summary collapse

Constructor Details

#initialize(xpath, example_group) ⇒ HaveXPath

Returns a new instance of HaveXPath.



4
5
6
7
8
9
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 4

def initialize(xpath, example_group)
  self.matcher = Matcher.new(
    :xpath => xpath,
    :example_group => example_group
  )
end

Instance Method Details

#failure_messageObject



33
34
35
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 33

def failure_message
  matcher.failure_message
end

#failure_message_when_negatedObject



37
38
39
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 37

def failure_message_when_negated
  matcher.failure_message_when_negated
end

#matches?(xml) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 29

def matches?(xml)
  matcher.matches?(xml)
end

#with_attr(attr) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 20

def with_attr(attr)
  self.matcher = AttrMatcher.new(
    :xpath => matcher.full_xpath,
    :attr => attr
  )

  self
end

#with_text(text) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rspec-xml/xml_matchers/have_xpath.rb', line 11

def with_text(text)
  self.matcher = TextMatcher.new(
    :xpath => matcher.full_xpath,
    :text => text.to_s
  )

  self
end