Skip to content

Instantly share code, notes, and snippets.

/response Secret

Created Jul 24, 2013
Embed
What would you like to do?
Running: spec/models/subscription_spec.rb
Subscription
should belong to plan
should belong to user
should require user_id to be set
should require case sensitive unique value for user_id
should require stripe_customer_token to be set
#create_stripe_customer
the subscription record
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 2 interaction(s): { [post https://api.stripe.com/v1/customers] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703576,\n \"id\": \"cus_2G6bk6Rac3Ebo1\","], [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703576,\n \"id\": \"cus_2G6bk6Rac3Ebo1\","] }
[Cassette: 'test_this'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[webmock] Handling request: [post https://api.stripe.com/v1/customers] (disabled: false)
[Cassette: 'test_this'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 0 interaction(s): { }
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Checking if [post https://api.stripe.com/v1/customers] matches [post https://api.stripe.com/v1/customers] using [:method, :uri]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] method (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] uri (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Found matching interaction for [post https://api.stripe.com/v1/customers] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703576,\n \"id\": \"cus_2G6bk6Rac3Ebo1\","]
[webmock] Identified request type (stubbed_by_vcr) for [post https://api.stripe.com/v1/customers]
[webmock] Handling request: [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] (disabled: false)
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Checking if [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] matches [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] using [:method, :uri]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] method (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] vs [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] uri (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] vs [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1]
[Cassette: 'Subscription/#create_stripe_customer/the subscription record/has a stripe customer token'] Found matching interaction for [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703576,\n \"id\": \"cus_2G6bk6Rac3Ebo1\","]
[webmock] Identified request type (stubbed_by_vcr) for [get https://api.stripe.com/v1/customers/cus_2G6bk6Rac3Ebo1]
has a stripe customer token
stripe customer record
[Cassette: 'test_this'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[webmock] Handling request: [post https://api.stripe.com/v1/customers] (disabled: false)
[Cassette: 'test_this'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 0 interaction(s): { }
[webmock] Identified request type (recordable) for [post https://api.stripe.com/v1/customers]
[Cassette: 'test_this'] Recorded HTTP interaction [post https://api.stripe.com/v1/customers] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
[webmock] Handling request: [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] (disabled: false)
[webmock] Identified request type (recordable) for [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
[Cassette: 'test_this'] Recorded HTTP interaction [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
has a description
[Cassette: 'Subscription/#create_stripe_customer/stripe customer record/has an email'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[Cassette: 'Subscription/#create_stripe_customer/stripe customer record/has an email'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 2 interaction(s): { [post https://api.stripe.com/v1/customers] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703574,\n \"id\": \"cus_2G6bCHTBOiH35i\","], [get https://api.stripe.com/v1/customers/cus_2G6bCHTBOiH35i] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703574,\n \"id\": \"cus_2G6bCHTBOiH35i\","] }
[Cassette: 'test_this'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[webmock] Handling request: [post https://api.stripe.com/v1/customers] (disabled: false)
[Cassette: 'test_this'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 2 interaction(s): { [post https://api.stripe.com/v1/customers] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","], [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","] }
[Cassette: 'test_this'] Checking if [post https://api.stripe.com/v1/customers] matches [post https://api.stripe.com/v1/customers] using [:method, :uri]
[Cassette: 'test_this'] method (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'test_this'] uri (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'test_this'] Found matching interaction for [post https://api.stripe.com/v1/customers] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
[webmock] Identified request type (stubbed_by_vcr) for [post https://api.stripe.com/v1/customers]
[webmock] Handling request: [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] (disabled: false)
[Cassette: 'test_this'] Checking if [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] matches [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] using [:method, :uri]
[Cassette: 'test_this'] method (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] vs [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
[Cassette: 'test_this'] uri (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] vs [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
[Cassette: 'test_this'] Found matching interaction for [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
[webmock] Identified request type (stubbed_by_vcr) for [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
has an email (FAILED - 1)
Failures:
1) Subscription#create_stripe_customer stripe customer record has an email
Failure/Error: subject.email.should == user.email
expected: "bob3@example.com"
got: "bob2@example.com" (using ==)
# ./spec/models/subscription_spec.rb:41:in `block (4 levels) in <top (required)>'
# -e:1:in `<main>'
Finished in 2.21 seconds
8 examples, 1 failure
Failed examples:
rspec ./spec/models/subscription_spec.rb:40 # Subscription#create_stripe_customer stripe customer record has an email
15:10:48 - INFO - Running: ./spec/models/subscription_spec.rb:40
Run options: include {:locations=>{"./spec/models/subscription_spec.rb"=>[40]}}
Subscription
#create_stripe_customer
stripe customer record
[Cassette: 'test_this'] Initialized with options: {:record=>:once, :match_requests_on=>[:method, :uri], :allow_unused_http_interactions=>true, :serialize_with=>:json, :persist_with=>:file_system}
[webmock] Handling request: [post https://api.stripe.com/v1/customers] (disabled: false)
[Cassette: 'test_this'] Initialized HTTPInteractionList with request matchers [:method, :uri] and 2 interaction(s): { [post https://api.stripe.com/v1/customers] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","], [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] => [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","] }
[Cassette: 'test_this'] Checking if [post https://api.stripe.com/v1/customers] matches [post https://api.stripe.com/v1/customers] using [:method, :uri]
[Cassette: 'test_this'] method (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'test_this'] uri (matched): current request [post https://api.stripe.com/v1/customers] vs [post https://api.stripe.com/v1/customers]
[Cassette: 'test_this'] Found matching interaction for [post https://api.stripe.com/v1/customers] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
[webmock] Identified request type (stubbed_by_vcr) for [post https://api.stripe.com/v1/customers]
[webmock] Handling request: [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] (disabled: false)
[Cassette: 'test_this'] Checking if [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] matches [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] using [:method, :uri]
[Cassette: 'test_this'] method (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] vs [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
[Cassette: 'test_this'] uri (matched): current request [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] vs [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
[Cassette: 'test_this'] Found matching interaction for [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK] at index 0: [200 "{\n \"object\": \"customer\",\n \"created\": 1374703837,\n \"id\": \"cus_2G6gqVDCZQcNPK\","]
[webmock] Identified request type (stubbed_by_vcr) for [get https://api.stripe.com/v1/customers/cus_2G6gqVDCZQcNPK]
has an email (FAILED - 1)
Failures:
1) Subscription#create_stripe_customer stripe customer record has an email
Failure/Error: subject.email.should == user.email
expected: "bob1@example.com"
got: "bob2@example.com" (using ==)
# ./spec/models/subscription_spec.rb:41:in `block (4 levels) in <top (required)>'
# -e:1:in `<main>'
Finished in 0.7461 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/models/subscription_spec.rb:40 # Subscription#create_stripe_customer stripe customer record has an email
describe "#create_stripe_customer" do
before do
VCR.use_cassette "test_this" do
@subscription = build(:subscription, user: user)
@subscription.create_stripe_customer
@subscription.save
@stripe_customer = Stripe::Customer.retrieve @subscription.stripe_customer_token
end
end
context "the subscription record" do
subject { @subscription }
it "has a stripe customer token", vcr: {match_requests_on: [:method, :uri]} do
subject.stripe_customer_token.should_not be_blank
end
end
context "stripe customer record" do
subject { @stripe_customer }
it "has a description" do
subject.description.should == user.id.to_s
end
it "has an email" do
subject.email.should == user.email
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment