rspec-stripe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05512b6ddcbfa7a5bb9f103342b47ba5a4fdd8e6
4
- data.tar.gz: 2496b4b322b68869cdfeff2d1ec56c45f44d2e02
3
+ metadata.gz: daade85cd92797b42206cb26d6315c567a6221f9
4
+ data.tar.gz: b1478da2c27f3a35c7a7eb9a4f734d693fbda435
5
5
  SHA512:
6
- metadata.gz: 7e159ef49ad43beab92b085691c5030ed167a30df5b935e3846cc8ba1bec92077be56d0208c741642b8eefae9e1c437211f940bb21ca858fbc388752e81cbf80
7
- data.tar.gz: 3b54f7060a6f98bb27e748c13e7fa41dcf688a7f1bda285ccb6a740aa986bbeb6892c31be59cc309769120f46609a0a51aa3ae3d7f37012872a6edee8ca837ff
6
+ metadata.gz: 706614aa10bd7f12d6a382e8ca579d468cd59f3639dd7913e8da149a71287b4135cf72d3d5a7dc7c41910c740cec017218432a66774234589c818f96b23026ef
7
+ data.tar.gz: b9d59f7e601507397dcaba837fa80e396a5d9b837aa7c68b9b528b2f02392f61e1673c94736c70eccd18e1c487c6280d3d0fea0050e52e0ec538920a37e9e9ee
data/README.md CHANGED
@@ -36,7 +36,7 @@ Installation
36
36
 
37
37
  1. Include `gem 'rspec-stripe'` in your Gemfile
38
38
  2. `bundle install`
39
- 3. In your spec_helper.rb file, include `require 'rspec-stripe'` at the top.
39
+ 3. In your spec_helper.rb file, include `require 'rspec-stripe'` at the top.
40
40
  4. Bootstrap it for RSpec:
41
41
 
42
42
  ```
@@ -44,3 +44,28 @@ RSpecStripe.configure do |config|
44
44
  config.configure_rspec_metadata!
45
45
  end
46
46
  ```
47
+
48
+ Options Available
49
+ ============
50
+
51
+ There are several options available to include in the stripe hash. The main options are `customer, plan, card, subscription`.
52
+
53
+ ### Customer
54
+ For a new customer, use the value `:new` in your hash. New customers will be created and then destroyed just for this spec. This is the recommended use case as rspec-stripe wants to make setup repeatable and easy.
55
+
56
+ For an existing customer, use the `"cus_something"` Stripe ID in your hash. Existing customers will not be destroyed when the spec is finished.
57
+
58
+ ### Plan
59
+ For a new plan, use the value `:new` or any plan id that doesn't exist in your Stripe instance. New plans will be created and then destroyed just for this spec. This is the recommended use case. Currently, you cannot specify the plan details and a default is used. This will be expanded on in upcoming versions.
60
+
61
+ For an existing plan, use the `"plan_id"` Stripe Plan ID in your hash. Existing plans will not be destroyed when the spec is finished.
62
+
63
+ ### Card
64
+ Cards are always created new when specified. There are several different built-in card types given from the Stripe Docs. These card names are `:visa :mastercard :amex :discover :diners :jcb :card_declined :incorrect_number :invalid_expiry_month :invalid_expiry_year :invalid_cvc`. You can pass any of these card names for the card hash value and that card will be created as a default for the current customer and then delete it when done with the spec.
65
+
66
+ Card requires that `customer` is defined and will raise an exception if the customer is not given (either new or existing is fine).
67
+
68
+ ### Subscription
69
+ Subscriptions are always created new when specified. Use the value `"plan_id"` for the subscription field. The subscription will be created with this plan and then deleted after the spec.
70
+
71
+ Subscription requires that `customer` is defined and will raise an exception if the customer is not given (either new or existing is fine).
@@ -10,11 +10,7 @@ module RSpecStripe
10
10
  @customer = customer_factory.get if recipes[:customer]
11
11
  @plan = plan_factory.get if recipes[:plan]
12
12
  @card = card_factory.get if recipes[:card]
13
-
14
- if recipes[:subscription]
15
- @card ||= card_factory.get
16
- @subscription = subscription_factory.get
17
- end
13
+ @subscription = subscription_factory.get if recipes[:subscription]
18
14
  end
19
15
 
20
16
  def cleanup!
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.require_paths = ["lib"]
13
13
  s.files = `git ls-files`.split("\n")
14
14
 
15
- s.version = "0.0.3"
15
+ s.version = "0.0.4"
16
16
  s.required_ruby_version = '>= 2.0.0'
17
17
  s.required_rubygems_version = '>= 1.6.2'
18
18
  end
@@ -5,6 +5,8 @@ require 'fakeweb'
5
5
  # making the calls that we want
6
6
  FakeWeb.allow_net_connect = false
7
7
 
8
+ # All runner options here are what would hash in rspec's stripe: hash syntax
9
+ # This is an authority on what options are available in any version
8
10
  describe RSpecStripe::Runner do
9
11
  describe "customer" do
10
12
  let(:customer_double) { double(Stripe::Customer) }
@@ -55,7 +57,7 @@ describe RSpecStripe::Runner do
55
57
  }
56
58
 
57
59
  it "creates the plan" do
58
- runner = RSpecStripe::Runner.new({plan: "test"})
60
+ runner = RSpecStripe::Runner.new({plan: :new})
59
61
  runner.call!
60
62
  end
61
63
 
@@ -125,8 +127,6 @@ describe RSpecStripe::Runner do
125
127
  end
126
128
 
127
129
  describe "subscription" do
128
- let(:card_double) { double(Stripe::Card) }
129
-
130
130
  context "without a customer" do
131
131
  it "raises error" do
132
132
  runner = RSpecStripe::Runner.new({subscription: "test"})
@@ -143,27 +143,13 @@ describe RSpecStripe::Runner do
143
143
  expect(stub).to receive(:create).once.with(plan: "test")
144
144
  stub
145
145
  }
146
- expect(customer_double).to receive(:cards).once {
147
- stub = double("cards")
148
- expect(stub).to receive(:create).once.with(card: hash_including(number: card_number)) { card_double }
149
- stub
150
- }
151
146
  }
152
147
 
153
- context "without a card specified" do
154
- let(:card_number) { "4242424242424242" }
155
-
156
- it "creates a generic card and subscription" do
157
- runner = RSpecStripe::Runner.new({customer: "id", subscription: "test"})
158
- runner.call!
159
- end
160
- end
161
-
162
148
  context "with a card specified" do
163
149
  let(:card_number) { "5555555555554444" }
164
150
 
165
151
  it "creates the specified card subscription" do
166
- runner = RSpecStripe::Runner.new({customer: "id", subscription: "test", card: :mastercard})
152
+ runner = RSpecStripe::Runner.new({customer: "id", subscription: "test"})
167
153
  runner.call!
168
154
  end
169
155
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Bussey