Permission is granted for use, copying, modification, distribution, and distribution of modified versions of this work as long as the above copyright notice is included.
+++
ContainerHelper | = | MockContainerHelper.new |
SpecModule | = | RSpec |
SpecModule | = | Spec |
ANY | = | AnyMatcher.new |
respond_to? | -> | flexmock_respond_to? |
Save the original definition of respond_to? for use a bit later. |
flexmock_container | [RW] | |
flexmock_name | [R] | |
framework_adapter | [R] |
Class method to make sure that verify is called at the end of a test. One mock object will be created for each name given to the use method. The mocks will be passed to the block as arguments. If no names are given, then a single anonymous mock object will be created.
At the end of the use block, each mock object will be verified to make sure the proper number of calls have been made.
Usage:
FlexMock.use("name") do |mock| # Creates a mock named "name" mock.should_receive(:meth). returns(0).once end # mock is verified here
NOTE: If you include FlexMock::TestCase into your test case file, you can create mocks that will be automatically verified in the test teardown by using the flexmock method.
Verify that each method that had an explicit expected count was actually called that many times.
Declare that the mock object should expect methods by providing a recorder for the methods and having the user invoke the expected methods in a block. Further expectations may be applied the result of the recording call.
Example Usage:
mock.should_expect do |record| record.add(Integer, 4) { |a, b| a + b }.at_least.once
Declare that the mock object should receive a message with the given name.
If more than one method name is given, then the mock object should expect to receive all the listed melthods. If a hash of method name/value pairs is given, then the each method will return the associated result. Any expectations applied to the result of should_receive will be applied to all the methods defined in the argument list.
An expectation object for the method name is returned as the result of this method. Further expectation constraints can be added by chaining to the result.
See Expectation for a list of declarators that can be used.