Module: Spec::Mocks::Methods
Instance Method Summary collapse
-
#__reset_mock ⇒ Object
:nodoc:.
-
#__verify ⇒ Object
:nodoc:.
-
#method_missing(sym, *args, &block) ⇒ Object
:nodoc:.
-
#received_message?(sym, *args, &block) ⇒ Boolean
:nodoc:.
- #should_not_receive(sym, &block) ⇒ Object
- #should_receive(sym, opts = {}, &block) ⇒ Object
- #stub!(sym) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
:nodoc:
28 29 30 31 |
# File 'lib/spec/mocks/methods.rb', line 28 def method_missing(sym, *args, &block) #:nodoc: __mock_handler.instance_eval {@messages_received << [sym, args, block]} super(sym, *args, &block) end |
Instance Method Details
#__reset_mock ⇒ Object
:nodoc:
24 25 26 |
# File 'lib/spec/mocks/methods.rb', line 24 def __reset_mock #:nodoc: __mock_handler.reset end |
#__verify ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/spec/mocks/methods.rb', line 20 def __verify #:nodoc: __mock_handler.verify end |
#received_message?(sym, *args, &block) ⇒ Boolean
:nodoc:
16 17 18 |
# File 'lib/spec/mocks/methods.rb', line 16 def (sym, *args, &block) #:nodoc: __mock_handler.(sym, *args, &block) end |
#should_not_receive(sym, &block) ⇒ Object
8 9 10 |
# File 'lib/spec/mocks/methods.rb', line 8 def should_not_receive(sym, &block) __mock_handler.(caller(1)[0], sym, &block) end |
#should_receive(sym, opts = {}, &block) ⇒ Object
4 5 6 |
# File 'lib/spec/mocks/methods.rb', line 4 def should_receive(sym, opts={}, &block) __mock_handler.(opts[:expected_from] || caller(1)[0], sym, opts, &block) end |
#stub!(sym) ⇒ Object
12 13 14 |
# File 'lib/spec/mocks/methods.rb', line 12 def stub!(sym) __mock_handler.add_stub(caller(1)[0], sym) end |