RSpec::Mocks::AnyInstance

Public Instance Methods

__recorder() click to toggle source

@private

    # File lib/rspec/mocks/any_instance.rb, line 40
40:       def __recorder
41:         @__recorder ||= AnyInstance::Recorder.new(self)
42:       end
any_instance() click to toggle source

Used to set stubs and message expectations on any instance of a given class. Returns a [Recorder](Recorder), which records messages like `stub` and `should_receive` for later playback on instances of the class.

@example

    Car.any_instance.should_receive(:go)
    race = Race.new
    race.cars << Car.new
    race.go # assuming this delegates to all of its cars
            # this example would pass

    Account.any_instance.stub(:balance) { Money.new(:USD, 25) }
    Account.new.balance # => Money.new(:USD, 25))

@return [Recorder]

    # File lib/rspec/mocks/any_instance.rb, line 25
25:       def any_instance
26:         RSpec::Mocks::space.add(self)
27:         __recorder
28:       end
rspec_verify() click to toggle source

@private

    # File lib/rspec/mocks/any_instance.rb, line 31
31:       def rspec_verify
32:         __recorder.verify
33:         super
34:       ensure
35:         __recorder.stop_all_observation!
36:         @__recorder = nil
37:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.