Module: Kernel

Defined in:
lib/stump/mock.rb,
lib/stump/stub.rb

Instance Method Summary collapse

Instance Method Details

#mock(method, options = {}, &block) ⇒ Object

Create a pure mock object rather than mocking specific methods on an object.

Examples

my_mock = mock(:thing, :return => "whee!")
my_mock.thing    # => "whee"


57
58
59
60
61
# File 'lib/stump/mock.rb', line 57

def mock(method, options = {}, &block)
  mock_object = Object.new
  mock_object.mock!(method, options, &block)
  mock_object
end

#stub(method, options = {}, &block) ⇒ Object

Create a pure stub object.

Examples

stubbalicious = stub(:failure, "wat u say?")
stubbalicious.failure     # => "wat u say?"


28
29
30
31
32
33
# File 'lib/stump/stub.rb', line 28

def stub(method, options = {}, &block)
  stub_object = Object.new
  stub_object.stub!(method, options, &block)

  stub_object
end