Sha256: 13bb8795841918b185b27bfe385bce17bdee8c9e91993e54e0e6c08393dedcce
Contents?: true
Size: 1.22 KB
Versions: 6
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require "savon/mock" module Savon module SpecHelper class Interface def mock! Savon.observers << self end def unmock! Savon.observers.clear end def expects(operation_name) expectation = MockExpectation.new(operation_name) expectations << expectation expectation end def expectations @expectations ||= [] end def notify(operation_name, builder, globals, locals) expectation = expectations.shift if expectation expectation.actual(operation_name, builder, globals, locals) expectation.verify! expectation.response! else raise ExpectationError, "Unexpected request to the #{operation_name.inspect} operation." end rescue ExpectationError @expectations.clear raise end def verify! return if expectations.empty? expectations.each(&:verify!) rescue ExpectationError @expectations.clear raise end end def savon @savon ||= Interface.new end def verify_mocks_for_rspec super if defined? super savon.verify! end end end
Version data entries
6 entries across 6 versions & 1 rubygems