Sha256: ffb681a6c65657cedc396f3a6a305dda4cddc155ed7bfdb993445b946ae64b9f

Contents?: true

Size: 1.08 KB

Versions: 28

Compression:

Stored size: 1.08 KB

Contents

module Shoulda
  module Matchers
    module Doublespeak
      # @private
      class MethodCall
        attr_accessor :return_value
        attr_reader :method_name, :args, :caller, :block, :object, :double

        def initialize(args)
          @method_name = args.fetch(:method_name)
          @args = args.fetch(:args)
          @caller = args.fetch(:caller)
          @block = args[:block]
          @double = args[:double]
          @object = args[:object]
          @return_value = nil
        end

        def with_return_value(return_value)
          dup.tap do |call|
            call.return_value = return_value
          end
        end

        def ==(other)
          other.is_a?(self.class) &&
            method_name == other.method_name &&
            args == other.args &&
            block == other.block &&
            double == other.double &&
            object == other.object
        end

        def to_hash
          { method_name: method_name, args: args }
        end

        def inspect
          "#<#{self.class.name} #{to_hash.inspect}>"
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
shoulda-matchers-6.4.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-6.3.1 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-6.3.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-6.2.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-6.1.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-6.0.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-5.3.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-5.2.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-5.1.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-5.0.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-5.0.0.rc1 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.5.1 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.5.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.4.1 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.4.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.3.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.2.0 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.1.2 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.1.1 lib/shoulda/matchers/doublespeak/method_call.rb
shoulda-matchers-4.1.0 lib/shoulda/matchers/doublespeak/method_call.rb