Module: RSpec::SpyOn::ExampleMethods
- Defined in:
- lib/rspec/spy_on/example_methods.rb
Instance Method Summary collapse
-
#spy_on(target, *messages) ⇒ target
Enables an RSpec::Mocks::TestDouble or any other object to act as a test spy.
Instance Method Details
#spy_on(target, *messages) ⇒ target
Enables an RSpec::Mocks::TestDouble or any other object to act as a test spy. Delegates to RSpec::Mocks to configure the allowing of the messages
In particular, spy_on
makes this act of configuring real objects
as spies easier by providing more concise syntax for configuring
spying on multiple methods while forwarding the messages along
to the original implementations.
22 23 24 25 26 27 28 29 |
# File 'lib/rspec/spy_on/example_methods.rb', line 22 def spy_on(target, *) if target.is_a?(RSpec::Mocks::TestDouble) .each { |m| RSpec::Mocks.(target, m) } else .each { |m| allow_partial(target, m) } end target end |