Sha256: f439e6809372e661bb3c0ee0f40ebaf7568063d7ff0bd0b5c8485d6eee783f6f

Contents?: true

Size: 874 Bytes

Versions: 7

Compression:

Stored size: 874 Bytes

Contents

module Spec
  module Mocks
    class Mock
      include Methods

      # Creates a new mock with a +name+ (that will be used in error messages only)
      # == Options:
      # * <tt>:null_object</tt> - if true, the mock object acts as a forgiving null object allowing any message to be sent to it.
      def initialize(name, options={})
        @name = name
        @options = options
      end

      def method_missing(sym, *args, &block)
        __mock_proxy.instance_eval {@messages_received << [sym, args, block]}
        begin
          return self if __mock_proxy.null_object?
          super(sym, *args, &block)
        rescue NoMethodError
          __mock_proxy.raise_unexpected_message_error sym, *args
        end
      end
      
      def inspect
        "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
has_finder-0.1.1 spec/rails/vendor/plugins/rspec/lib/spec/mocks/mock.rb
has_finder-0.1.2 spec/rails/vendor/plugins/rspec/lib/spec/mocks/mock.rb
has_finder-0.1.3 spec/rails/vendor/plugins/rspec/lib/spec/mocks/mock.rb
rspec-1.0.5 lib/spec/mocks/mock.rb
rspec-1.0.6 lib/spec/mocks/mock.rb
rspec-1.0.7 lib/spec/mocks/mock.rb
rspec-1.0.8 lib/spec/mocks/mock.rb