class RSpec::Mocks::AnyInstance::Chain

def constrained_to_any_of?(*constraints)

def constrained_to_any_of?(*constraints)
  constraints.any? do |constraint|
    messages.any? do |message|
      message.first.first == constraint
    end
  end
end

def last_message

def last_message
  messages.last.first.first unless messages.empty?
end

def messages

def messages
  @messages ||= []
end

def playback!(instance)

def playback!(instance)
  messages.inject(instance) do |instance, message|
    instance.send(*message.first, &message.last)
  end
end

def record(rspec_method_name, *args, &block)

def record(rspec_method_name, *args, &block)
  verify_invocation_order(rspec_method_name, *args, &block)
  messages << [args.unshift(rspec_method_name), block]
  self
end