Topic: noob stub/mock (ActiveMerchant)

Hi Group

I'm still waiting for the light to come on with stubbing/mocking and
the syntax for each. I have simple method in my Order class like
so....

 def credit_card
   ActiveMerchant::Billing::CreditCard.new(
     :type               => card_type,
     :number             => card_number,
     :verification_value => card_verification,
     :month              => card_expires_on.blank? ? Time.now.month :
card_expires_on.month,
     :year               => card_expires_on.blank? ? Time.now.year :
card_expires_on.year,
     :first_name         => first_name,
     :last_name          => last_name
   )
 end

This method should return valid if the card is valid.
http://activemerchant.rubyforge.org/cla … tCard.html

I started out with the code below but then confusion set in. If anyone has the
time to help me understand or write the proper spec for this method I
think it will help me better understand how to stub or mock a 3rd
party item like this. I just watched the peepcode screencast and I've
watched the railscasts. I'm just trying to apply my meager
understanding to my own project now.

it "should validate credit card" do
     gateway = stub('gateway')
     gateway.should_recieve(:valid)
     ActiveMerchant::Billing::CreditCard.stub(:new).and_return
gateway
   end

I also have a credit card Factory setup, but I'm not sure where or how
I apply this to the stub.

Thanks in advance!