Module: RSpecXML::XMLMatchers

Defined in:
lib/rspec-xml/xml_matchers.rb,
lib/rspec-xml/xml_matchers/have_xpath.rb,
lib/rspec-xml/xml_matchers/have_xpath/matcher.rb,
lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb

Defined Under Namespace

Classes: HaveXPath

Instance Method Summary collapse

Instance Method Details

#have_xpath(xpath) ⇒ Object



9
10
11
# File 'lib/rspec-xml/xml_matchers.rb', line 9

def have_xpath(xpath)
  HaveXPath.new(xpath, self)
end

#within(xpath, &example_group_block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rspec-xml/xml_matchers.rb', line 13

def within(xpath, &example_group_block)
  return unless block_given?

  instance_exec(example_group_block) do
    @xpath_stack ||= [] 
    @xpath_stack.push xpath
    yield
    @xpath_stack.pop
  end
end