Sha256: 74ce923549869013c2f9728a071a8dbaa0850a521eaf676f154f8bf66e9e3f17

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe CreditCard do
  
  it { should belong_to :subscription }
  
  
  it 'should produce credit card from valid attributes' do
      credit_card = Factory(:credit_card)
      credit_card.active_merchant_card.class.should == ActiveMerchant::Billing::CreditCard
   end
   
  describe 'Card create' do
    before(:each) do
      @credit_card = Factory(:credit_card)
    end
   it 'should retain card number' do 
      @credit_card.card_number.should_not == nil
    end
      
    it 'should retain masked card number' do 
      @credit_card.card_number.should == "XXXXXXXXXXXX1111"
    end
  
    it 'should retain expiration date' do
      @credit_card.expiration_date.should == "10/#{Date.today.year + 1}"
    end
  end
  
  
  describe 'Card Update' do
    before(:each) do
      @plan = Factory.build(:plan, :name => "Gold", :price => 20)
      @contact_info = Factory.build(:contact_info)

      @credit_card = Factory.build(:credit_card)
      @subscription = Factory(:subscription, :contact_info => @contact_info, :plan => @plan, :credit_card => @credit_card)
    end
  
  
    it 'should update card on auth.net' do
      @credit_card.should_receive(:update_payment_profile)
      @credit_card.update_attributes(
            # :first_name =>"new",
            # :last_name  => "value",
            :card_type => "Visa",
            :card_number => "4111111111111111",
            :card_verification => "545",
            :expiry_month => "10",
            :expiry_year => "#{Date.today.year + 1}")
          
     
    end
  
  end 
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saasaparilla-0.2.2 spec/models/credit_card_spec.rb
saasaparilla-0.2.1 spec/models/credit_card_spec.rb