Sha256: 87d582bdca6d92f386a3680e5f2f3a4fb47de912273e01435ebcd907d9674c52

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

# Savon 2 sólo permite verificar los params del mensaje como un hash lo cual es poco flexible. Con esto permito pasarle xpaths.

module Savon
  module MessageMatcher
    def actual(operation_name, builder, globals, locals)
      super.update request: builder.to_s
    end

    def verify_message!
      if @expected[:message].respond_to? :verify!
        @expected[:message].verify! @actual[:request]
      else
        super
      end
    end
  end

  MockExpectation.prepend MessageMatcher
end

def has_path(paths)
  HasXPath.new(paths)
end

class HasXPath
  include RSpec::Matchers

  def initialize(paths)
    @paths = paths
  end

  def verify! xml
    @actual_xml = xml
    @paths.each do |(path, value)|
      @expected_xpath, @expected_value = path, value
      @actual_xml.should match_xpath @expected_xpath, @expected_value
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
afipws-2.3.0 spec/support/savon_extensions.rb
afipws-2.2.0 spec/support/savon_extensions.rb
afipws-2.1.0 spec/support/savon_extensions.rb
afipws-2.0.0 spec/support/savon_extensions.rb