-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpricing_spec.rb
More file actions
96 lines (78 loc) · 2.39 KB
/
pricing_spec.rb
File metadata and controls
96 lines (78 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# typed: false
require 'spec_helper'
RSpec.describe Squake::Pricing, :vcr do
let(:product_id) { 'product_026c41' }
describe '#quote' do
context 'when requesting with fixed carbon_quantity' do
subject(:pricing) do
described_class.quote(
client: squake_client,
carbon_quantity: 1000,
carbon_unit: 'kilogram',
product_id: product_id,
)
end
context 'when valid request' do
it_behaves_like 'successful pricing response'
end
context 'when invalid request' do
let(:product_id) { 'invalid' }
it_behaves_like 'failed pricing response'
end
end
context 'when requesting with expand argument' do
subject(:pricing) do
described_class.quote(
client: squake_client,
fixed_total: 1000,
product_id: product_id,
expand: %w[product price],
)
end
it_behaves_like 'successful pricing response'
it 'returns expanded product' do
pricing.result.product.tap do |product|
expect(product).to be_a(Squake::Model::Product)
expect(product.id).to eq(product_id)
end
end
it 'returns expanded price' do
pricing.result.price.tap do |price|
expect(price).to be_a(Squake::Model::Price)
end
end
end
context 'when requesting with fixed total' do
subject(:pricing) do
described_class.quote(
client: squake_client,
fixed_total: 1000,
product_id: product_id,
)
end
context 'when valid request' do
it_behaves_like 'successful pricing response'
end
context 'when invalid request' do
let(:product_id) { 'invalid' }
it_behaves_like 'failed pricing response'
end
end
context 'when requesting with payment method' do
subject(:pricing) do
described_class.quote(
client: squake_client,
product_id: product_id,
payment_method: Squake::Model::PaymentMethod::Stripe,
fixed_total: 1000,
)
end
let(:product_id) { 'product_N7TnHY' }
it_behaves_like 'successful pricing response'
it 'contains payment link' do
expect(pricing.result.payment_link).to be_a(String)
expect(pricing.result.payment_link).to include('checkout.sandbox.squake.earth')
end
end
end
end