Sha256: 971b6cc7709326dae9b67c8f6a6b3a0cd8c4baf889b89942639cdd7dfb341544

Contents?: true

Size: 467 Bytes

Versions: 4

Compression:

Stored size: 467 Bytes

Contents

require 'nokogiri'

module APIMatchers
  module ResponseBody
    class HaveXmlNode < Base
      def matches?(actual)
        @actual = actual
        xml = Nokogiri::XML(response_body)
        node = xml.xpath("//#{@expected_node}").text

        if @with_value
          node == @with_value.to_s
        elsif @expected_including_text
          node.to_s.include?(@expected_including_text)
        else
          node.present?
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
api_matchers-0.3.0 lib/api_matchers/response_body/have_xml_node.rb
api_matchers-0.2.0 lib/api_matchers/response_body/have_xml_node.rb
api_matchers-0.1.1 lib/api_matchers/response_body/have_xml_node.rb
api_matchers-0.1.0 lib/api_matchers/response_body/have_xml_node.rb