Module: Ww::Double::Mock
- Defined in:
- lib/ww/double/mock.rb
Defined Under Namespace
Classes: Expectation
Instance Method Summary collapse
- #mock(verb, path, options = {}, &block) ⇒ Object
- #testing_thread ⇒ Object
- #testing_thread=(thread) ⇒ Object
- #verify ⇒ Object
Instance Method Details
#mock(verb, path, options = {}, &block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ww/double/mock.rb', line 30 def mock(verb, path, = {}, &block) expect = Expectation.new(verb, path, .delete(:verify)) expectations << expect action = Double.unbound_action(self, expect.identifier, block) stub(verb, path) do |*args| expect.verify(request, self.class.testing_thread) expect.executed! action.bind(self).call(*args) end end |
#testing_thread ⇒ Object
26 27 28 |
# File 'lib/ww/double/mock.rb', line 26 def testing_thread @testing_thread end |
#testing_thread=(thread) ⇒ Object
22 23 24 |
# File 'lib/ww/double/mock.rb', line 22 def testing_thread=(thread) @testing_thread = thread end |
#verify ⇒ Object
43 44 45 |
# File 'lib/ww/double/mock.rb', line 43 def verify raise MockError unless expectations.all? {|mock| mock.executed? } end |