add more tests to check Stripe exceptions

This commit is contained in:
Rishabh Saxena 2016-08-10 13:54:24 +05:30
parent 922440fb77
commit a78804b94d
3 changed files with 62 additions and 5 deletions

View file

@ -1,4 +1,5 @@
require 'spec_helper'
require 'stripe_mock'
feature Registration do
let!(:ticket) { create(:ticket) }
@ -8,15 +9,19 @@ feature Registration do
context 'as a participant' do
before(:each) do
sign_in participant
StripeMock.start
end
after(:each) do
StripeMock.stop
sign_out
end
let(:stripe_helper) { StripeMock.create_test_helper }
context 'who is not registered' do
scenario 'purchases a ticket', feature: true, js: true do
scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do
visit root_path
click_link 'Register'
@ -32,6 +37,12 @@ feature Registration do
expect(flash).to eq('Please pay here to purchase tickets.')
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
expect(purchase.quantity).to eq(2)
# token = stripe_helper.generate_card_token
# merge token, email and submit form
# page.execute_script("$('form').submit()")
expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
end
end
end