Sha256: 3f03c55b93062395e19d46fc83b8e1d6cf06ab641ffe2f8b11d93d85d7c55364

Contents?: true

Size: 839 Bytes

Versions: 6

Compression:

Stored size: 839 Bytes

Contents

module Shoulda
  module Matchers
    module Doublespeak
      # @private
      class ObjectDouble < BasicObject
        attr_reader :calls

        def initialize
          @calls = []
          @calls_by_method_name = {}
        end

        def calls_to(method_name)
          @calls_by_method_name[method_name] || []
        end

        def respond_to?(name, include_private = nil)
          true
        end

        def method_missing(method_name, *args, &block)
          call = MethodCall.new(
            method_name: method_name,
            args: args,
            block: block,
            caller: ::Kernel.caller
          )
          calls << call
          (calls_by_method_name[method_name] ||= []) << call
          nil
        end

        protected

        attr_reader :calls_by_method_name
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shoulda-matchers-3.1.3 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-3.1.2 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-3.1.1 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-3.1.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-3.0.1 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-3.0.0 lib/shoulda/matchers/doublespeak/object_double.rb