stripe-ruby-mock 1.8.4.2 → 1.8.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,10 +12,12 @@ module StripeMock
12
12
  end
13
13
  end
14
14
 
15
- def self.prepare_card_error(code)
15
+ def self.prepare_card_error(code, *handler_names)
16
+ handler_names.push(:new_charge) if handler_names.count == 0
17
+
16
18
  args = CardErrors.argument_map[code]
17
19
  raise StripeMockError.new("Unrecognized stripe card error code: #{code}") if args.nil?
18
- self.prepare_error Stripe::CardError.new(*args), :new_charge
20
+ self.prepare_error Stripe::CardError.new(*args), *handler_names
19
21
  end
20
22
 
21
23
  module CardErrors
@@ -1,4 +1,4 @@
1
1
  module StripeMock
2
2
  # stripe-ruby-mock version
3
- VERSION = "1.8.4.2"
3
+ VERSION = "1.8.4.3"
4
4
  end
@@ -87,6 +87,18 @@ shared_examples 'Stripe Error Mocking' do
87
87
  expect { Stripe::Charge.create() }.to raise_error Stripe::CardError
88
88
  end
89
89
 
90
+ it "mocks a card error with a given handler" do
91
+ StripeMock.prepare_card_error(:incorrect_cvc, :new_customer)
92
+ expect { Stripe::Charge.create() }.to_not raise_error
93
+
94
+ expect { Stripe::Customer.create() }.to raise_error {|e|
95
+ expect(e).to be_a(Stripe::CardError)
96
+ expect(e.http_status).to eq(402)
97
+ expect(e.code).to eq('incorrect_cvc')
98
+ expect(e.param).to eq('cvc')
99
+ }
100
+ end
101
+
90
102
  it "mocks an incorrect number card error" do
91
103
  StripeMock.prepare_card_error(:incorrect_number)
92
104
  expect_card_error 'incorrect_number', 'number'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-ruby-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.4.2
4
+ version: 1.8.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stripe