stripe-ruby-mock 2.5.8 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +6 -6
  4. data/README.md +8 -8
  5. data/lib/stripe_mock.rb +3 -0
  6. data/lib/stripe_mock/api/errors.rb +31 -28
  7. data/lib/stripe_mock/api/webhooks.rb +3 -0
  8. data/lib/stripe_mock/data.rb +140 -13
  9. data/lib/stripe_mock/instance.rb +10 -3
  10. data/lib/stripe_mock/request_handlers/balance_transactions.rb +2 -2
  11. data/lib/stripe_mock/request_handlers/helpers/subscription_helpers.rb +1 -1
  12. data/lib/stripe_mock/request_handlers/helpers/token_helpers.rb +1 -1
  13. data/lib/stripe_mock/request_handlers/invoices.rb +6 -1
  14. data/lib/stripe_mock/request_handlers/payment_intents.rb +175 -0
  15. data/lib/stripe_mock/request_handlers/payment_methods.rb +138 -0
  16. data/lib/stripe_mock/request_handlers/products.rb +1 -0
  17. data/lib/stripe_mock/request_handlers/setup_intents.rb +93 -0
  18. data/lib/stripe_mock/request_handlers/subscriptions.rb +17 -4
  19. data/lib/stripe_mock/request_handlers/validators/param_validators.rb +95 -9
  20. data/lib/stripe_mock/test_strategies/base.rb +42 -8
  21. data/lib/stripe_mock/test_strategies/live.rb +23 -12
  22. data/lib/stripe_mock/test_strategies/mock.rb +6 -2
  23. data/lib/stripe_mock/version.rb +1 -1
  24. data/lib/stripe_mock/webhook_fixtures/charge.failed.json +166 -38
  25. data/lib/stripe_mock/webhook_fixtures/customer.created.json +1 -0
  26. data/lib/stripe_mock/webhook_fixtures/customer.updated.json +1 -0
  27. data/lib/stripe_mock/webhook_fixtures/product.created.json +34 -0
  28. data/lib/stripe_mock/webhook_fixtures/product.deleted.json +34 -0
  29. data/lib/stripe_mock/webhook_fixtures/product.updated.json +38 -0
  30. data/spec/instance_spec.rb +6 -6
  31. data/spec/server_spec.rb +2 -1
  32. data/spec/shared_stripe_examples/account_examples.rb +1 -1
  33. data/spec/shared_stripe_examples/balance_transaction_examples.rb +3 -3
  34. data/spec/shared_stripe_examples/bank_examples.rb +3 -3
  35. data/spec/shared_stripe_examples/card_examples.rb +4 -4
  36. data/spec/shared_stripe_examples/charge_examples.rb +9 -22
  37. data/spec/shared_stripe_examples/coupon_examples.rb +1 -1
  38. data/spec/shared_stripe_examples/customer_examples.rb +44 -30
  39. data/spec/shared_stripe_examples/dispute_examples.rb +2 -2
  40. data/spec/shared_stripe_examples/error_mock_examples.rb +8 -7
  41. data/spec/shared_stripe_examples/external_account_examples.rb +3 -3
  42. data/spec/shared_stripe_examples/invoice_examples.rb +41 -39
  43. data/spec/shared_stripe_examples/invoice_item_examples.rb +1 -1
  44. data/spec/shared_stripe_examples/payment_intent_examples.rb +137 -0
  45. data/spec/shared_stripe_examples/payment_method_examples.rb +185 -0
  46. data/spec/shared_stripe_examples/payout_examples.rb +2 -2
  47. data/spec/shared_stripe_examples/plan_examples.rb +135 -92
  48. data/spec/shared_stripe_examples/product_examples.rb +155 -0
  49. data/spec/shared_stripe_examples/refund_examples.rb +25 -21
  50. data/spec/shared_stripe_examples/setup_intent_examples.rb +68 -0
  51. data/spec/shared_stripe_examples/subscription_examples.rb +281 -310
  52. data/spec/shared_stripe_examples/subscription_items_examples.rb +3 -2
  53. data/spec/shared_stripe_examples/transfer_examples.rb +6 -6
  54. data/spec/shared_stripe_examples/webhook_event_examples.rb +11 -11
  55. data/spec/spec_helper.rb +3 -4
  56. data/spec/stripe_mock_spec.rb +2 -2
  57. data/spec/support/shared_contexts/stripe_validator_spec.rb +8 -0
  58. data/spec/support/stripe_examples.rb +3 -0
  59. data/stripe-ruby-mock.gemspec +2 -2
  60. metadata +47 -27
  61. data/spec/shared_stripe_examples/product_example.rb +0 -65
@@ -0,0 +1,185 @@
1
+ require 'spec_helper'
2
+
3
+ shared_examples 'PaymentMethod API' do
4
+
5
+ let(:billing_details) do
6
+ {
7
+ address: {
8
+ city: 'North New Portland',
9
+ country: 'US',
10
+ line1: '2631 Bloomfield Way',
11
+ line2: 'Apartment 5B',
12
+ postal_code: '05555',
13
+ state: 'ME'
14
+ },
15
+ email: 'john@example.com',
16
+ name: 'John Doe',
17
+ phone: '555-555-5555'
18
+ }
19
+ end
20
+ let(:card_details) do
21
+ {
22
+ number: 4242_4242_4242_4242,
23
+ exp_month: 9,
24
+ exp_year: (Time.now.year + 5),
25
+ cvc: 999
26
+ }
27
+ end
28
+
29
+ # post /v1/payment_methods
30
+ describe 'Create a PaymentMethod', live: true do
31
+ let(:payment_method) do
32
+ Stripe::PaymentMethod.create(
33
+ type: type,
34
+ billing_details: billing_details,
35
+ card: card_details,
36
+ metadata: {
37
+ order_id: '123456789'
38
+ }
39
+ )
40
+ end
41
+ let(:type) { 'card' }
42
+
43
+ it 'creates a payment method with a valid id', live: false do
44
+ expect(payment_method.id).to match(/^test_pm/)
45
+ end
46
+
47
+ it 'creates a payment method with a billing address' do
48
+ expect(payment_method.billing_details.address.city).to eq('North New Portland')
49
+ expect(payment_method.billing_details.address.country).to eq('US')
50
+ expect(payment_method.billing_details.address.line1).to eq('2631 Bloomfield Way')
51
+ expect(payment_method.billing_details.address.line2).to eq('Apartment 5B')
52
+ expect(payment_method.billing_details.address.postal_code).to eq('05555')
53
+ expect(payment_method.billing_details.address.state).to eq('ME')
54
+ expect(payment_method.billing_details.email).to eq('john@example.com')
55
+ expect(payment_method.billing_details.name).to eq('John Doe')
56
+ expect(payment_method.billing_details.phone).to eq('555-555-5555')
57
+ end
58
+
59
+ it 'creates a payment method with metadata' do
60
+ expect(payment_method.metadata.order_id).to eq('123456789')
61
+ end
62
+
63
+ context 'when type is invalid' do
64
+ let(:type) { 'bank_account' }
65
+
66
+ it 'raises invalid requestion exception' do
67
+ expect { payment_method }.to raise_error(Stripe::InvalidRequestError)
68
+ end
69
+ end
70
+ end
71
+
72
+ # get /v1/payment_methods/:id
73
+ describe 'Retrieve a PaymentMethod', live: true do
74
+ it 'retrieves a given payment method' do
75
+ customer = Stripe::Customer.create
76
+ original = Stripe::PaymentMethod.create(type: 'card', card: card_details)
77
+ Stripe::PaymentMethod.attach(original.id, customer: customer.id)
78
+
79
+ payment_method = Stripe::PaymentMethod.retrieve(original.id)
80
+
81
+ expect(payment_method.id).to eq(original.id)
82
+ expect(payment_method.type).to eq(original.type)
83
+ expect(payment_method.customer).to eq(customer.id)
84
+ end
85
+
86
+ it "cannot retrieve a payment_method that doesn't exist" do
87
+ expect { Stripe::PaymentMethod.retrieve('nope') }.to raise_error { |e|
88
+ expect(e).to be_a Stripe::InvalidRequestError
89
+ expect(e.param).to eq('payment_method')
90
+ expect(e.http_status).to eq(404)
91
+ }
92
+ end
93
+
94
+ end
95
+
96
+ # get /v1/payment_methods
97
+ describe "List a Customer's PaymentMethods", live: true do
98
+ let(:customer) { Stripe::Customer.create }
99
+ let(:customer2) { Stripe::Customer.create }
100
+ before do
101
+ 3.times do
102
+ payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
103
+ Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
104
+ end
105
+ end
106
+
107
+ it 'lists all payment methods' do
108
+ expect(Stripe::PaymentMethod.list(customer: customer.id, type: 'card').count).to eq(3)
109
+ end
110
+
111
+ context 'when passing a limit' do
112
+ it 'only lists the limited number of payment methods' do
113
+ expect(Stripe::PaymentMethod.list(customer: customer.id, type: 'card', limit: 2).count).to eq(2)
114
+ end
115
+ end
116
+
117
+ context 'when listing the payment methods of another customer' do
118
+ it 'does not list any payment methods' do
119
+ expect(Stripe::PaymentMethod.list(customer: customer2.id, type: 'card').count).to eq(0)
120
+ end
121
+ end
122
+ end
123
+
124
+ # post /v1/payment_methods/:id/attach
125
+ describe 'Attach a PaymentMethod to a Customer', live: true do
126
+ let(:customer) { Stripe::Customer.create }
127
+ let(:payment_method) { Stripe::PaymentMethod.create(type: 'card', card: card_details) }
128
+
129
+ it 'attaches a payment method to a customer' do
130
+ expect { Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id) }
131
+ .to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
132
+ .from(nil).to(customer.id)
133
+ end
134
+
135
+ context "when the customer doesn't exist" do
136
+ it 'raises invalid requestion exception' do
137
+ expect { Stripe::PaymentMethod.attach(payment_method.id, customer: 'cus_invalid') }
138
+ .to raise_error(Stripe::InvalidRequestError)
139
+ end
140
+ end
141
+ end
142
+
143
+ # post /v1/payment_methods/:id/detach
144
+ describe 'Detach a PaymentMethod from a Customer', live: true do
145
+ let(:customer) { Stripe::Customer.create }
146
+ let(:payment_method) do
147
+ payment_method = Stripe::PaymentMethod.create(type: 'card', card: card_details)
148
+ Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
149
+ end
150
+
151
+ it 'detaches a PaymentMethod from a customer' do
152
+ expect { Stripe::PaymentMethod.detach(payment_method.id) }
153
+ .to change { Stripe::PaymentMethod.retrieve(payment_method.id).customer }
154
+ .from(customer.id).to(nil)
155
+ end
156
+ end
157
+
158
+ # post /v1/payment_methods/:id
159
+ describe 'Update a PaymentMethod', live: true do
160
+ let(:customer) { Stripe::Customer.create }
161
+ let(:payment_method) do
162
+ Stripe::PaymentMethod.create(type: 'card', card: card_details)
163
+ end
164
+
165
+ it 'updates the card for the payment method' do
166
+ Stripe::PaymentMethod.attach(payment_method.id, customer: customer.id)
167
+
168
+ original_card_exp_month = payment_method.card.exp_month
169
+ new_card_exp_month = 12
170
+
171
+ expect do
172
+ Stripe::PaymentMethod.update(payment_method.id, card: { exp_month: new_card_exp_month })
173
+ end.to change { Stripe::PaymentMethod.retrieve(payment_method.id).card.exp_month }
174
+ .from(original_card_exp_month).to(new_card_exp_month)
175
+ end
176
+
177
+ context 'without a customer' do
178
+ it 'raises invalid requestion exception' do
179
+ expect do
180
+ Stripe::PaymentMethod.update(payment_method.id, card: { exp_month: 12 })
181
+ end.to raise_error(Stripe::InvalidRequestError)
182
+ end
183
+ end
184
+ end
185
+ end
@@ -19,11 +19,11 @@ shared_examples 'Payout API' do
19
19
  end
20
20
 
21
21
  it "without params retrieves all tripe payouts" do
22
- expect(Stripe::Payout.all.count).to eq(3)
22
+ expect(Stripe::Payout.list.count).to eq(3)
23
23
  end
24
24
 
25
25
  it "accepts a limit param" do
26
- expect(Stripe::Payout.all(limit: 2).count).to eq(2)
26
+ expect(Stripe::Payout.list(limit: 2).count).to eq(2)
27
27
  end
28
28
  end
29
29
 
@@ -1,93 +1,73 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  shared_examples 'Plan API' do
4
+ let(:product) { stripe_helper.create_product }
5
+ let(:product_id) { product.id }
6
+
7
+ let(:plan_attributes) { {
8
+ :id => "plan_abc123",
9
+ :product => product_id,
10
+ :nickname => "My Mock Plan",
11
+ :amount => 9900,
12
+ :currency => "usd",
13
+ :interval => "month"
14
+ } }
15
+ let(:plan) { Stripe::Plan.create(plan_attributes) }
16
+
17
+ let(:plan_attributes_without_id){ plan_attributes.merge(id: nil) }
18
+ let(:plan_without_id){ Stripe::Plan.create(plan_attributes_without_id) }
19
+
20
+ let(:plan_attributes_with_trial) { plan_attributes.merge(id: "prod_TRIAL", :trial_period_days => 30) }
21
+ let(:plan_with_trial) { Stripe::Plan.create(plan_attributes_with_trial) }
22
+
23
+ let(:metadata) { {:description => "desc text", :info => "info text"} }
24
+ let(:plan_attributes_with_metadata) { plan_attributes.merge(id: "prod_META", metadata: metadata) }
25
+ let(:plan_with_metadata) { Stripe::Plan.create(plan_attributes_with_metadata) }
26
+
27
+ before(:each) do
28
+ product
29
+ end
4
30
 
5
31
  it "creates a stripe plan" do
6
- plan = Stripe::Plan.create(
7
- :id => 'pid_1',
8
- :name => 'The Mock Plan',
9
- :amount => 9900,
10
- :currency => 'USD',
11
- :interval => 1,
12
- :product => {
13
- :name => 'A product'
14
- },
15
- :metadata => {
16
- :description => "desc text",
17
- :info => "info text"
18
- },
19
- :trial_period_days => 30
20
- )
21
-
22
- expect(plan.id).to eq('pid_1')
23
- expect(plan.name).to eq('The Mock Plan')
32
+ expect(plan.id).to eq('plan_abc123')
33
+ expect(plan.nickname).to eq('My Mock Plan')
24
34
  expect(plan.amount).to eq(9900)
25
35
 
26
- expect(plan.currency).to eq('USD')
27
- expect(plan.interval).to eq(1)
36
+ expect(plan.currency).to eq('usd')
37
+ expect(plan.interval).to eq("month")
28
38
 
29
- expect(plan.metadata.description).to eq('desc text')
30
- expect(plan.metadata.info).to eq('info text')
39
+ expect(plan_with_metadata.metadata.description).to eq('desc text')
40
+ expect(plan_with_metadata.metadata.info).to eq('info text')
31
41
 
32
- expect(plan.trial_period_days).to eq(30)
42
+ expect(plan_with_trial.trial_period_days).to eq(30)
33
43
  end
34
44
 
35
-
36
45
  it "creates a stripe plan without specifying ID" do
37
- plan = Stripe::Plan.create(
38
- :name => 'The Mock Plan',
39
- :amount => 9900,
40
- :currency => 'USD',
41
- :interval => 1,
42
- :product => {
43
- :name => 'A product'
44
- }
45
- )
46
-
47
- expect(plan.id).to match(/^test_plan/)
46
+ expect(plan_attributes_without_id[:id]).to be_nil
47
+ expect(plan_without_id.id).to match(/^test_plan_1/)
48
48
  end
49
49
 
50
50
  it "stores a created stripe plan in memory" do
51
- plan = Stripe::Plan.create(
52
- :id => 'pid_2',
53
- :name => 'The Memory Plan',
54
- :amount => 1100,
55
- :currency => 'USD',
56
- :interval => 1,
57
- :product => {
58
- :name => 'A product'
59
- }
60
- )
61
- plan2 = Stripe::Plan.create(
62
- :id => 'pid_3',
63
- :name => 'The Bonk Plan',
64
- :amount => 7777,
65
- :currency => 'USD',
66
- :interval => 1,
67
- :product => {
68
- :name => 'A product'
69
- }
70
- )
51
+ plan
52
+ plan2 = Stripe::Plan.create(plan_attributes.merge(id: "plan_def456", amount: 299))
53
+
71
54
  data = test_data_source(:plans)
72
55
  expect(data[plan.id]).to_not be_nil
73
- expect(data[plan.id][:amount]).to eq(1100)
74
-
56
+ expect(data[plan.id][:amount]).to eq(9900)
75
57
  expect(data[plan2.id]).to_not be_nil
76
- expect(data[plan2.id][:amount]).to eq(7777)
58
+ expect(data[plan2.id][:amount]).to eq(299)
77
59
  end
78
60
 
79
-
80
61
  it "retrieves a stripe plan" do
81
- original = stripe_helper.create_plan(amount: 1331)
62
+ original = stripe_helper.create_plan(product: product_id, amount: 1331, id: 'plan_943843')
82
63
  plan = Stripe::Plan.retrieve(original.id)
83
64
 
84
65
  expect(plan.id).to eq(original.id)
85
66
  expect(plan.amount).to eq(original.amount)
86
67
  end
87
68
 
88
-
89
69
  it "updates a stripe plan" do
90
- stripe_helper.create_plan(id: 'super_member', amount: 111)
70
+ stripe_helper.create_plan(id: 'super_member', product: product_id, amount: 111)
91
71
 
92
72
  plan = Stripe::Plan.retrieve('super_member')
93
73
  expect(plan.amount).to eq(111)
@@ -98,7 +78,6 @@ shared_examples 'Plan API' do
98
78
  expect(plan.amount).to eq(789)
99
79
  end
100
80
 
101
-
102
81
  it "cannot retrieve a stripe plan that doesn't exist" do
103
82
  expect { Stripe::Plan.retrieve('nope') }.to raise_error {|e|
104
83
  expect(e).to be_a Stripe::InvalidRequestError
@@ -108,7 +87,7 @@ shared_examples 'Plan API' do
108
87
  end
109
88
 
110
89
  it "deletes a stripe plan" do
111
- stripe_helper.create_plan(id: 'super_member', amount: 111)
90
+ stripe_helper.create_plan(id: 'super_member', product: product_id, amount: 111)
112
91
 
113
92
  plan = Stripe::Plan.retrieve('super_member')
114
93
  expect(plan).to_not be_nil
@@ -123,10 +102,10 @@ shared_examples 'Plan API' do
123
102
  end
124
103
 
125
104
  it "retrieves all plans" do
126
- stripe_helper.create_plan(id: 'Plan One', amount: 54321)
127
- stripe_helper.create_plan(id: 'Plan Two', amount: 98765)
105
+ stripe_helper.create_plan(id: 'Plan One', product: product_id, amount: 54321)
106
+ stripe_helper.create_plan(id: 'Plan Two', product: product_id, amount: 98765)
128
107
 
129
- all = Stripe::Plan.all
108
+ all = Stripe::Plan.list
130
109
  expect(all.count).to eq(2)
131
110
  expect(all.map &:id).to include('Plan One', 'Plan Two')
132
111
  expect(all.map &:amount).to include(54321, 98765)
@@ -134,33 +113,31 @@ shared_examples 'Plan API' do
134
113
 
135
114
  it 'retrieves plans with limit' do
136
115
  101.times do | i|
137
- stripe_helper.create_plan(id: "Plan #{i}", amount: 11)
116
+ stripe_helper.create_plan(id: "Plan #{i}", product: product_id, amount: 11)
138
117
  end
139
- all = Stripe::Plan.all(limit: 100)
118
+ all = Stripe::Plan.list(limit: 100)
140
119
 
141
120
  expect(all.count).to eq(100)
142
121
  end
143
122
 
144
- it 'validates the amount' do
145
- expect {
146
- Stripe::Plan.create(
147
- :id => 'pid_1',
148
- :name => 'The Mock Plan',
149
- :amount => 99.99,
150
- :currency => 'USD',
151
- :interval => 'month',
152
- :product => {
153
- :name => 'A product'
154
- }
155
- )
156
- }.to raise_error(Stripe::InvalidRequestError, "Invalid integer: 99.99")
157
- end
158
-
159
- describe "Validation", :live => true do
160
- let(:params) { stripe_helper.create_plan_params }
123
+ describe "Validations", :live => true do
124
+ include_context "stripe validator"
125
+ let(:params) { stripe_helper.create_plan_params(product: product_id) }
161
126
  let(:subject) { Stripe::Plan.create(params) }
162
127
 
163
- describe "Required Parameters" do
128
+ describe "Associations" do
129
+ let(:not_found_product_id){ "prod_NONEXIST" }
130
+ let(:not_found_message) { stripe_validator.not_found_message(Stripe::Product, not_found_product_id) }
131
+ let(:params) { stripe_helper.create_plan_params(product: not_found_product_id) }
132
+ let(:products) { stripe_helper.list_products(100).data }
133
+
134
+ it "validates associated product" do
135
+ expect(products.map(&:id)).to_not include(not_found_product_id)
136
+ expect { subject }.to raise_error(Stripe::InvalidRequestError, not_found_message)
137
+ end
138
+ end
139
+
140
+ describe "Presence" do
164
141
  after do
165
142
  params.delete(@name)
166
143
  message =
@@ -172,13 +149,49 @@ shared_examples 'Plan API' do
172
149
  expect { subject }.to raise_error(Stripe::InvalidRequestError, message)
173
150
  end
174
151
 
175
- it("requires a product") { @name = :product }
176
- it("requires an amount") { @name = :amount }
177
- it("requires a currency") { @name = :currency }
178
- it("requires an interval") { @name = :interval }
152
+ it("validates presence of interval") { @name = :interval }
153
+ it("validates presence of currency") { @name = :currency }
154
+ it("validates presence of product") { @name = :product }
155
+ it("validates presence of amount") { @name = :amount }
156
+ end
157
+
158
+ describe "Inclusion" do
159
+ let(:invalid_interval) { "OOPS" }
160
+ let(:invalid_interval_message) { stripe_validator.invalid_plan_interval_message }
161
+ let(:invalid_interval_params) { params.merge({interval: invalid_interval}) }
162
+ let(:plan_with_invalid_interval) { Stripe::Plan.create(invalid_interval_params) }
163
+
164
+ before(:each) do
165
+ product
166
+ end
167
+
168
+ it "validates inclusion of interval" do
169
+ expect { plan_with_invalid_interval }.to raise_error(Stripe::InvalidRequestError, invalid_interval_message)
170
+ end
171
+
172
+ let(:invalid_currency) { "OOPS" }
173
+ let(:invalid_currency_message) { stripe_validator.invalid_currency_message(invalid_currency) }
174
+ let(:invalid_currency_params) { params.merge({currency: invalid_currency}) }
175
+ let(:plan_with_invalid_currency) { Stripe::Plan.create(invalid_currency_params) }
176
+
177
+ it "validates inclusion of currency" do
178
+ expect { plan_with_invalid_currency }.to raise_error(Stripe::InvalidRequestError, invalid_currency_message)
179
+ end
180
+ end
181
+
182
+ describe "Numericality" do
183
+ let(:invalid_integer) { 99.99 }
184
+ let(:invalid_integer_message) { stripe_validator.invalid_integer_message(invalid_integer)}
185
+
186
+ it 'validates amount is an integer' do
187
+ expect {
188
+ Stripe::Plan.create( plan_attributes.merge({amount: invalid_integer}) )
189
+ }.to raise_error(Stripe::InvalidRequestError, invalid_integer_message)
190
+ end
179
191
  end
180
192
 
181
193
  describe "Uniqueness" do
194
+ let(:already_exists_message) { stripe_validator.already_exists_message(Stripe::Plan) }
182
195
 
183
196
  it "validates for uniqueness" do
184
197
  stripe_helper.delete_plan(params[:id])
@@ -186,9 +199,39 @@ shared_examples 'Plan API' do
186
199
  Stripe::Plan.create(params)
187
200
  expect {
188
201
  Stripe::Plan.create(params)
189
- }.to raise_error(Stripe::InvalidRequestError, "Plan already exists.")
202
+ }.to raise_error(Stripe::InvalidRequestError, already_exists_message)
190
203
  end
191
204
  end
205
+
206
+ end
207
+
208
+ describe "Mock Data" do
209
+ let(:mock_object) { StripeMock::Data.mock_plan }
210
+ let(:known_attributes) { [
211
+ :id,
212
+ :object,
213
+ :active,
214
+ :aggregate_usage,
215
+ :amount,
216
+ :billing_scheme,
217
+ :created,
218
+ :currency,
219
+ :interval,
220
+ :interval_count,
221
+ :livemode,
222
+ :metadata,
223
+ :nickname,
224
+ :product,
225
+ :tiers,
226
+ :tiers_mode,
227
+ :transform_usage,
228
+ :trial_period_days,
229
+ :usage_type
230
+ ] }
231
+
232
+ it "includes all retreived attributes" do
233
+ expect(mock_object.keys).to eql(known_attributes)
234
+ end
192
235
  end
193
236
 
194
237
  end