Class: MacSpec::MockingFramework::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/mac_spec/mocking_framework/mock.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Mock

Returns a new instance of Mock.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mac_spec/mocking_framework/mock.rb', line 4

def initialize(name, options={})
  (class<<self;self;end).instance_eval do
    if options[:null_object]
      define_method :method_missing do |name, *args, &block|
        Mock.new(:null_object, :null_object => true)
      end
    end
    options[:stubs] && options[:stubs].each do |stub_method, return_value|
      define_method stub_method do |*args|
        return_value
      end
    end
  end
end