Sha256: 4b81ee559763202b2bf4371ff7ffc960785cffbe4a2965e9f06a2575fad8ca50

Contents?: true

Size: 923 Bytes

Versions: 13

Compression:

Stored size: 923 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 respond_to_missing?(_name, _include_all)
          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

13 entries across 13 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/doublespeak/object_double.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/doublespeak/object_double.rb