module Facon::Mockable
A module containing convenient methods for creating mocks, stubs and expectations.
Public Instance Methods
Source
# File lib/facon/mockable.rb, line 12 def mock(name, stubs = {}) Mock.new(name, stubs) end
Shortcut for creating a Facon::Mock
instance.
Example¶ ↑
mock = mock('test mock', :foo => 'bar') mock.foo # => 'bar'
Source
# File lib/facon/mockable.rb, line 39 def mock_proxy @mock_proxy ||= Proxy.new(self, Mock === self ? @name : self.class.name) end
Returns the mock proxy object.
Source
# File lib/facon/mockable.rb, line 24 def should_not_receive(method, &block) mock_proxy.add_negative_expectation(caller(1)[0], method, &block) end
Source
# File lib/facon/mockable.rb, line 20 def should_receive(method, &block) mock_proxy.add_expectation(caller(1)[0], method, &block) end
Source
# File lib/facon/mockable.rb, line 30 def spec_verify mock_proxy.verify end
Verifies that the expectations set on this mock are all met, otherwise raises a MockExpectationError
.
Source
# File lib/facon/mockable.rb, line 16 def stub!(method) mock_proxy.add_stub(caller(1)[0], method) end