@macro [attach] record
@method $1(*args, &block) Records the `$1` message for playback against an instance that invokes a method stubbed or mocked using `any_instance`. @see RSpec::Mocks::MessageExpectation#$1
# File lib/rspec/mocks/any_instance/chain.rb, line 15 def record(method_name) class_eval(" def #{method_name}(*args, &block) record(:#{method_name}, *args, &block) end ", __FILE__, __LINE__ + 1) end
@private
# File lib/rspec/mocks/any_instance/chain.rb, line 47 def constrained_to_any_of?(*constraints) constraints.any? do |constraint| messages.any? do |message| message.first.first == constraint end end end
@private
# File lib/rspec/mocks/any_instance/chain.rb, line 56 def expectation_fulfilled! @expectation_fulfilled = true end
@private
# File lib/rspec/mocks/any_instance/chain.rb, line 40 def playback!(instance) messages.inject(instance) do |_instance, message| _instance.__send__(*message.first, &message.last) end end
# File lib/rspec/mocks/any_instance/chain.rb, line 66 def last_message messages.last.first.first unless messages.empty? end
# File lib/rspec/mocks/any_instance/chain.rb, line 62 def messages @messages ||= [] end
# File lib/rspec/mocks/any_instance/chain.rb, line 70 def record(rspec_method_name, *args, &block) verify_invocation_order(rspec_method_name, *args, &block) messages << [args.unshift(rspec_method_name), block] self end