stripe-ruby-mock 1.8.4.2 → 1.8.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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),
|
20
|
+
self.prepare_error Stripe::CardError.new(*args), *handler_names
|
19
21
|
end
|
20
22
|
|
21
23
|
module CardErrors
|
data/lib/stripe_mock/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stripe
|