[mocha-developer] expects with returns that returns the return value of the actual method

Steve Eichert steve.eichert at gmail.com
Wed Jun 20 23:39:22 EDT 2007

I'm trying to test some code that's using active_merchant using the
following test.  What I'd like to be able to do is verify that purchase is
called, however, rather than specifying the return value for purchase with
returns, I'd like it to return the actual return value provided if you
called the non mocked purchase method.  Is this possible?

def test_charge
    gateway = ActiveMerchant::Billing::Base.gateway(:bogus).new
    ActiveMerchant::Billing::Base.mode = :test

    member = Member.new
    member.credit_card_number = "1"
    member.expiration_date = "9/19/2007"
    member.payment_method = "bogus"
    member.first_name = "Steve"
    member.last_name = "Eichert"

    # gateway.expects(:purchase).returns(:non_mocked_return)


    assert member.paid

More information about the mocha-developer mailing list