Module: Kernel
- Defined in:
- lib/motion-spec.rb,
lib/motion-spec/mock/mock.rb,
lib/motion-spec/mock/stub.rb,
lib/motion-spec/extensions/kernel.rb
Instance Method Summary collapse
-
#mock(method, options = {}, &block) ⇒ Object
Create a pure mock object rather than mocking specific methods on an object.
- #print(*args) ⇒ Object
- #puts(*args) ⇒ Object
-
#stub(method, options = {}, &block) ⇒ Object
Create a pure stub object.
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"
58 59 60 61 62 |
# File 'lib/motion-spec/mock/mock.rb', line 58 def mock(method, = {}, &block) mock_object = Object.new mock_object.mock!(method, , &block) mock_object end |
#print(*args) ⇒ Object
61 62 63 |
# File 'lib/motion-spec.rb', line 61 def print(*args) puts *args # TODO end |
#puts(*args) ⇒ Object
57 58 59 |
# File 'lib/motion-spec.rb', line 57 def puts(*args) NSLog(args.join("\n")) end |
#stub(method, options = {}, &block) ⇒ Object
Create a pure stub object.
Examples
stubbalicious = stub(:failure, "wat u say?")
stubbalicious.failure # => "wat u say?"
31 32 33 34 35 36 |
# File 'lib/motion-spec/mock/stub.rb', line 31 def stub(method, = {}, &block) stub_object = Object.new stub_object.stub!(method, , &block) stub_object end |