Module: Ww::Double::Mock

Defined in:
lib/ww/double/mock.rb

Defined Under Namespace

Classes: Expectation

Instance Method Summary collapse

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, options = {}, &block)
  expect = Expectation.new(verb, path, options.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_threadObject



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

#verifyObject

Raises:



43
44
45
# File 'lib/ww/double/mock.rb', line 43

def verify
  raise MockError unless expectations.all? {|mock| mock.executed? }
end