Module: Gauntlt::Support::XmlHelper

Defined in:
lib/gauntlt/attack_adapters/support/xml_helper.rb

Instance Method Summary collapse

Instance Method Details

#assert_xml_does_not_include(filename, css) ⇒ Object


24
25
26
# File 'lib/gauntlt/attack_adapters/support/xml_helper.rb', line 24

def assert_xml_does_not_include(filename, css)
  raise "#{css} found in #{filename}" unless xml_at_css(filename, css).nil?
end

#assert_xml_includes(filename, css) ⇒ Object


20
21
22
# File 'lib/gauntlt/attack_adapters/support/xml_helper.rb', line 20

def assert_xml_includes(filename, css)
  raise "#{css} not found in #{filename}" if xml_at_css(filename, css).nil?
end

#load_xml_from_file(filename) ⇒ Object


6
7
8
9
10
11
12
# File 'lib/gauntlt/attack_adapters/support/xml_helper.rb', line 6

def load_xml_from_file(filename)
  content = ""
  prep_for_fs_check do
    content = IO.read(filename)
  end
  Nokogiri::XML(content)
end

#xml_at_css(filename, css) ⇒ Object


15
16
17
18
# File 'lib/gauntlt/attack_adapters/support/xml_helper.rb', line 15

def xml_at_css(filename, css)
  xml = load_xml_from_file(filename)
  xml.at_css(css)
end