Sha256: 7a8b6a7a945e73ba13c8ff1b6e927b08fbc0e15a7dd198dc4a623417244c0107

Contents?: true

Size: 632 Bytes

Versions: 13

Compression:

Stored size: 632 Bytes

Contents

require 'webmock/rspec'
require 'rosemary'

require 'libxml'

RSpec::Matchers.define :have_xml do |xpath, text|
  match do |body|
    parser = LibXML::XML::Parser.string body
    doc = parser.parse
    nodes = doc.find(xpath)
    nodes.empty?.should be_false
    if text
      nodes.each do |node|
        node.content.should == text
      end
    end
    true
  end

  failure_message_for_should do |body|
    "expected to find xml tag #{xpath} in:\n#{body}"
  end

  failure_message_for_should_not do |response|
    "expected not to find xml tag #{xpath} in:\n#{body}"
  end

  description do
    "have xml tag #{xpath}"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rosemary-0.3.12 spec/spec_helper.rb
rosemary-0.3.11 spec/spec_helper.rb
rosemary-0.3.10 spec/spec_helper.rb
rosemary-0.3.9 spec/spec_helper.rb
rosemary-0.3.8 spec/spec_helper.rb
rosemary-0.3.7 spec/spec_helper.rb
rosemary-0.3.6 spec/spec_helper.rb
rosemary-0.3.5 spec/spec_helper.rb
rosemary-0.3.4 spec/spec_helper.rb
rosemary-0.3.3 spec/spec_helper.rb
rosemary-0.3.2 spec/spec_helper.rb
rosemary-0.3.1 spec/spec_helper.rb
rosemary-0.3.0 spec/spec_helper.rb