Skip to content

Commit

Permalink
Adds spec to cover existing #valid_for_reuse? behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mscottford committed Mar 1, 2013
1 parent 972fbcd commit aff58c0
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/lib/card_reuse_spec.rb
Expand Up @@ -71,4 +71,43 @@
end
end
end

describe '#valid_for_resuse' do
let(:source) {
mock(:source).tap do |s|
s.stub(:gateway_payment_profile_id).and_return('gateway_payment_profile_id')
s.stub(:gateway_customer_profile_id).and_return('gateway_customer_profile_id')
s.stub(:deleted?).and_return(false)
end
}

it 'returns true for sources with all the required information' do
expect(fixture.valid_for_reuse?(source)).to be_true
end

it 'returns true for sources that are missing only gateway_payment_profile_id' do
source.stub(:gateway_payment_profile_id).and_return(nil)

expect(fixture.valid_for_reuse?(source)).to be_true
end

it 'returns true for sources that are missing only gateway_customer_profile_id' do
source.stub(:gateway_customer_profile_id).and_return(nil)

expect(fixture.valid_for_reuse?(source)).to be_true
end

it 'returns false for sources that are missing both gateway_payment_profile_id and gateway_customer_profile_id' do
source.stub(:gateway_payment_profile_id).and_return(nil)
source.stub(:gateway_customer_profile_id).and_return(nil)

expect(fixture.valid_for_reuse?(source)).to be_false
end

it 'returns false for sources that have been deleted' do
source.stub(:deleted?).and_return(true)

expect(fixture.valid_for_reuse?(source)).to be_false
end
end
end

0 comments on commit aff58c0

Please sign in to comment.