Class | Object |
In: |
lib/quarry/assert.rb
lib/quarry/stub/stub.rb lib/quarry/stub/mock.rb |
Parent: | Object |
Assert not an operational relationship. Read it as "assert not".
4.assert! == 4 #=> Assertion Error
AUHTOR‘S NOTE: This method would not be necessary if Ruby would allow +!=+ to be define as a method, or at least +!+ as a unary method.
# File lib/quarry/assert.rb, line 142 def assert! return Assertion::False.new(self) end
We can‘t remove the module per-say. So we have to just neuter it. This is a very weak solution, but it will suffice for the moment.
# File lib/quarry/stub/mock.rb, line 79 def remove(mock_module=nil) mock_module ||= @_mock obj = self mod = Module.new mock_module.__table__.each do |interface, result| meth = interface[0] mod.module_eval do define_method(meth, &obj.class.instance_method(meth).bind(obj)) end end extend(mod) end
We can‘t remove the module per-say. So we have to just neuter it. This is a very weak solution, but it will suffice for the moment.
# File lib/quarry/stub/stub.rb, line 77 def remove(stub_module=nil) stub_module ||= @_stub obj = self mod = Module.new stub_module.__table__.each do |interface, result| meth = interface[0] mod.module_eval do define_method(meth, &obj.class.instance_method(meth).bind(obj)) end end extend(mod) end