Class: RSpecStripe::Factory::Card
- Inherits:
-
Object
- Object
- RSpecStripe::Factory::Card
- Defined in:
- lib/rspec-stripe/factories/card.rb
Instance Attribute Summary collapse
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #get ⇒ Object
-
#initialize(id, customer) ⇒ Card
constructor
A new instance of Card.
- #recipes ⇒ Object
Constructor Details
#initialize(id, customer) ⇒ Card
Returns a new instance of Card.
5 6 7 8 |
# File 'lib/rspec-stripe/factories/card.rb', line 5 def initialize(id, customer) @id = id || :visa @customer = customer end |
Instance Attribute Details
#customer ⇒ Object
Returns the value of attribute customer.
3 4 5 |
# File 'lib/rspec-stripe/factories/card.rb', line 3 def customer @customer end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/rspec-stripe/factories/card.rb', line 3 def id @id end |
Instance Method Details
#cleanup ⇒ Object
23 24 25 26 |
# File 'lib/rspec-stripe/factories/card.rb', line 23 def cleanup get.delete rescue Stripe::InvalidRequestError # ignore end |
#get ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rspec-stripe/factories/card.rb', line 10 def get @get ||= begin customer.cards.create( card: { exp_month: "01", exp_year: "2025", cvc: "111", name: customer.id }.merge(recipes[id]) ) end end |
#recipes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspec-stripe/factories/card.rb', line 28 def recipes { visa: { number: "4242424242424242" }, mastercard: { number: "5555555555554444" }, amex: { number: "378282246310005" }, discover: { number: "6011111111111117" }, diners: { number: "30569309025904" }, jcb: { number: "3530111333300000" }, card_declined: { number: "4000000000000341" }, incorrect_number: { number: "4242424242424241" }, invalid_expiry_month: { number: "4242424242424242", exp_month: "13" }, invalid_expiry_year: { number: "4242424242424242", exp_year: "1970" }, invalid_cvc: { number: "4242424242424242", cvc: "99" } } end |