Module: MacSpec::MockingFramework::ObjectExtension
- Defined in:
- lib/mac_spec/mocking_framework/extensions/object_extension.rb
Instance Method Summary collapse
- #__macspec__reset! ⇒ Object
- #__macspec__verify ⇒ Object
- #should_not_receive(msg) ⇒ Object
- #should_receive(msg) ⇒ Object
- #stub!(hash) ⇒ Object
Instance Method Details
#__macspec__reset! ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/mac_spec/mocking_framework/extensions/object_extension.rb', line 56 def __macspec__reset! @__macspec__message_expectations && @__macspec__message_expectations.each do |me| if respond_to?(me.unique_alias) && respond_to?(me.msg) (class<<self;self;end).instance_eval do undef_method me.msg alias_method me.msg, me.unique_alias undef_method me.unique_alias end else end end @__macspec__message_expectations = nil end |
#__macspec__verify ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/mac_spec/mocking_framework/extensions/object_extension.rb', line 46 def __macspec__verify begin @__macspec__message_expectations && @__macspec__message_expectations.each do |me| me && me.verify end ensure __macspec__reset! end end |
#should_not_receive(msg) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mac_spec/mocking_framework/extensions/object_extension.rb', line 17 def should_not_receive(msg) @__macspec__message_expectations ||= [] = { :receiver => self, :positive => false, :msg => msg, :stub => false } = MacSpec::MockingFramework::MessageExpectation.new() @__macspec__message_expectations << return end |
#should_receive(msg) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mac_spec/mocking_framework/extensions/object_extension.rb', line 4 def should_receive(msg) @__macspec__message_expectations ||= [] = { :receiver => self, :positive => true, :msg => msg, :stub => false } = MacSpec::MockingFramework::MessageExpectation.new() @__macspec__message_expectations << return end |
#stub!(hash) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mac_spec/mocking_framework/extensions/object_extension.rb', line 30 def stub!(hash) hash = {hash => nil} unless Hash === hash @__macspec__message_expectations ||= [] hash.each do |meth_to_stub, ret_val| = { :receiver => self, :positive => true, :msg => meth_to_stub, :stub => true, :stub_return_value => ret_val } = MacSpec::MockingFramework::MessageExpectation.new() @__macspec__message_expectations << end end |