rspec-stripe 0.0.1 → 0.0.2g
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/rspec-stripe/factories/card.rb +13 -9
- data/lib/rspec-stripe/factories/customer.rb +12 -8
- data/lib/rspec-stripe/factories/plan.rb +18 -14
- data/lib/rspec-stripe/factories/subscription.rb +8 -5
- data/lib/rspec-stripe/runner.rb +7 -4
- data/rspec-stripe.gemspec +1 -1
- data/spec/basic_rspec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb9e0bb5492c01f84b7e5eb5cb2bdf775a2dd5f4
|
4
|
+
data.tar.gz: db27c2219c6ff83c437df214cac121dddcf4a63b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4ab1fea611fa86243da512bd98cd4183150c16d2a7dfc52ad985f38c9d697ae210b4b567a331d1235b040aafb292a15250af3f6ee6b8ad5d5cf826a6a86f3e
|
7
|
+
data.tar.gz: e6a415128cc150a0f38e236cbf84a0fd096dfb5e23a7b2c4faf199d04304a2f14488e133e7ecc51ffffea2bb059ec0c72bf27ee084a9da6f862343ba4b1359dc
|
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
.env
|
1
|
+
.env
|
2
|
+
*.gem
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module RSpecStripe::Factory
|
2
2
|
class Card
|
3
|
-
attr_accessor :
|
3
|
+
attr_accessor :id, :customer
|
4
4
|
|
5
5
|
def initialize(id, customer)
|
6
6
|
@id = id || :visa
|
@@ -8,14 +8,18 @@ module RSpecStripe::Factory
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def get
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
@get ||= begin
|
12
|
+
customer.cards.create(card: recipes[id].merge(
|
13
|
+
exp_month: "01",
|
14
|
+
exp_year: "2025",
|
15
|
+
cvc: "111",
|
16
|
+
name: customer.id
|
17
|
+
))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def cleanup
|
22
|
+
get.delete
|
19
23
|
end
|
20
24
|
|
21
25
|
def recipes
|
@@ -1,15 +1,19 @@
|
|
1
1
|
module RSpecStripe::Factory
|
2
2
|
Customer = Struct.new(:id) do
|
3
|
-
attr_accessor :should_delete
|
4
|
-
|
5
3
|
def get
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
@get ||= begin
|
5
|
+
if id == :new || id == true
|
6
|
+
@should_delete = true
|
7
|
+
Stripe::Customer.create
|
8
|
+
else
|
9
|
+
@should_delete = false
|
10
|
+
Stripe::Customer.retrieve(id)
|
11
|
+
end
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def cleanup
|
16
|
+
get.delete if @should_delete
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
@@ -1,20 +1,24 @@
|
|
1
1
|
module RSpecStripe::Factory
|
2
2
|
Plan = Struct.new(:id) do
|
3
|
-
attr_accessor :should_delete
|
4
|
-
|
5
3
|
def get
|
6
|
-
@
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
@get ||= begin
|
5
|
+
@should_delete = false
|
6
|
+
Stripe::Plan.retrieve(id)
|
7
|
+
rescue Stripe::InvalidRequestError
|
8
|
+
@should_delete = true
|
9
|
+
# Lookup the plan's details and then create it
|
10
|
+
Stripe::Plan.create(
|
11
|
+
amount: 2000,
|
12
|
+
interval: 'month',
|
13
|
+
name: 'Amazing Gold Plan',
|
14
|
+
currency: 'usd',
|
15
|
+
id: id
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def cleanup
|
21
|
+
get.delete if @should_delete
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module RSpecStripe::Factory
|
2
2
|
Subscription = Struct.new(:id, :customer) do
|
3
|
-
attr_accessor :should_delete
|
4
|
-
|
5
3
|
def get
|
6
|
-
@
|
7
|
-
|
8
|
-
|
4
|
+
@get ||= begin
|
5
|
+
cancel_subscriptions
|
6
|
+
customer.subscriptions.create(plan: id)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def cleanup
|
11
|
+
get.delete
|
9
12
|
end
|
10
13
|
|
11
14
|
private
|
data/lib/rspec-stripe/runner.rb
CHANGED
@@ -18,14 +18,17 @@ module RSpecStripe
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def cleanup!
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
customer.delete if customer_factory.should_delete
|
21
|
+
factories.reject(&:nil?).each do |factory|
|
22
|
+
factory.cleanup
|
23
|
+
end
|
25
24
|
end
|
26
25
|
|
27
26
|
private
|
28
27
|
|
28
|
+
def factories
|
29
|
+
[ @subscription_factory, @plan_factory, @card_factory, @customer_factory ]
|
30
|
+
end
|
31
|
+
|
29
32
|
def customer_factory
|
30
33
|
@customer_factory ||= RSpecStripe::Factory::Customer.new(recipes[:customer])
|
31
34
|
end
|
data/rspec-stripe.gemspec
CHANGED
data/spec/basic_rspec.rb
CHANGED
@@ -7,10 +7,16 @@ describe 'Basic' do
|
|
7
7
|
expect {
|
8
8
|
Stripe::Customer.retrieve(stripe_customer.id)
|
9
9
|
}.not_to raise_error
|
10
|
+
|
11
|
+
expect(stripe_plan).to eq(nil)
|
12
|
+
expect(stripe_subscription).to eq(nil)
|
10
13
|
end
|
11
14
|
|
12
15
|
it "gives a plan", stripe: { plan: "test" } do
|
13
16
|
expect(stripe_plan).not_to eq(nil)
|
17
|
+
|
18
|
+
expect(stripe_customer).to eq(nil)
|
19
|
+
expect(stripe_subscription).to eq(nil)
|
14
20
|
end
|
15
21
|
|
16
22
|
it "gives me a subscription", stripe: { customer: :new, plan: "test", subscription: "test" } do
|