Skip to content

Instantly share code, notes, and snippets.

/gist:588697967840ee97317f Secret

Created Jul 24, 2013
Embed
What would you like to do?
describe Subscription do
it { should belong_to(:plan) }
it { should belong_to(:user) }
it { should validate_presence_of(:user_id) }
it { should validate_uniqueness_of(:user_id) }
it { should validate_presence_of(:stripe_customer_token) }
let(:plan) { Plan.first }
let(:user) { FactoryGirl.create :user }
describe "#create_stripe_customer", vcr: {match_requests_on: [:method, :uri]} do
before do
@subscription = build(:subscription, user: user)
@subscription.create_stripe_customer
@subscription.save
@stripe_customer = Stripe::Customer.retrieve @subscription.stripe_customer_token
end
context "the subscription record" do
subject { @subscription }
its(:stripe_customer_token) { should_not be_blank }
end
context "stripe customer record" do
subject { @stripe_customer }
its(:description) { should == "#{user.id}" }
its(:email) { should == user.email }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment