Sha256: 218d53585b3aa995183ac2d49db833214ec4c629d9b22f3d238258ffd423a010

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

require 'rr'

module Bogus
  class InvocationMatcher < RR::Adapters::Rspec::InvocationMatcher
    def initialize(method, verifies_stub_definition, records_double_interactions)
      super(method)
      @verifies_stub_definition = verifies_stub_definition
      @records_double_interactions = records_double_interactions
      @stubbed_method_calls = []
    end

    def matches?(subject)
      @stubbed_method_calls.each do |name, args|
        @verifies_stub_definition.verify!(subject, name, args)
        @records_double_interactions.record(subject, name, args)
      end

      return super(subject.__inner_object__) if subject.respond_to?(:__inner_object__)
      return super(subject)
    end

    def method_missing(name, *args, &block)
      @stubbed_method_calls << [name, args]
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bogus-0.0.2 lib/bogus/invocation_matcher.rb
bogus-0.0.1 lib/bogus/invocation_matcher.rb