refactor tests
This commit is contained in:
parent
a78804b94d
commit
6bd2e5e335
2 changed files with 0 additions and 17 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'stripe_mock'
|
|
||||||
|
|
||||||
feature Registration do
|
feature Registration do
|
||||||
let!(:ticket) { create(:ticket) }
|
let!(:ticket) { create(:ticket) }
|
||||||
|
|
@ -9,16 +8,12 @@ feature Registration do
|
||||||
context 'as a participant' do
|
context 'as a participant' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
sign_in participant
|
sign_in participant
|
||||||
StripeMock.start
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
StripeMock.stop
|
|
||||||
sign_out
|
sign_out
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:stripe_helper) { StripeMock.create_test_helper }
|
|
||||||
|
|
||||||
context 'who is not registered' do
|
context 'who is not registered' do
|
||||||
|
|
||||||
scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do
|
scenario 'purchases and pays for a ticket succcessfully', feature: true, js: true do
|
||||||
|
|
@ -37,12 +32,6 @@ feature Registration do
|
||||||
expect(flash).to eq('Please pay here to purchase tickets.')
|
expect(flash).to eq('Please pay here to purchase tickets.')
|
||||||
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
purchase = TicketPurchase.where(user_id: participant.id, ticket_id: ticket.id).first
|
||||||
expect(purchase.quantity).to eq(2)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ describe Payment do
|
||||||
context 'when the connection to Stripe drops' do
|
context 'when the connection to Stripe drops' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_error(Stripe::APIConnectionError.new)
|
StripeMock.prepare_error(Stripe::APIConnectionError.new)
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::APIConnectionError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -98,7 +97,6 @@ describe Payment do
|
||||||
context 'when there is a Stripe API Error' do
|
context 'when there is a Stripe API Error' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_error(Stripe::APIError.new)
|
StripeMock.prepare_error(Stripe::APIError.new)
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::APIError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -106,7 +104,6 @@ describe Payment do
|
||||||
context 'when there is authentication error' do
|
context 'when there is authentication error' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_error(Stripe::AuthenticationError.new)
|
StripeMock.prepare_error(Stripe::AuthenticationError.new)
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::AuthenticationError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -114,7 +111,6 @@ describe Payment do
|
||||||
context 'when there is a card error' do
|
context 'when there is a card error' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_card_error(:card_declined)
|
StripeMock.prepare_card_error(:card_declined)
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::CardError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -122,7 +118,6 @@ describe Payment do
|
||||||
context 'when the request to Stripe is invalid' do
|
context 'when the request to Stripe is invalid' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_error(Stripe::InvalidRequestError.new('Your request is invalid.', code: 402))
|
StripeMock.prepare_error(Stripe::InvalidRequestError.new('Your request is invalid.', code: 402))
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::InvalidRequestError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -130,7 +125,6 @@ describe Payment do
|
||||||
context 'when Stripe rate limit exceeds' do
|
context 'when Stripe rate limit exceeds' do
|
||||||
it 'raises exception' do
|
it 'raises exception' do
|
||||||
StripeMock.prepare_error(Stripe::RateLimitError.new)
|
StripeMock.prepare_error(Stripe::RateLimitError.new)
|
||||||
expect{ Stripe::Charge.create }.to raise_error(Stripe::RateLimitError)
|
|
||||||
expect{ payment.purchase }.not_to raise_error
|
expect{ payment.purchase }.not_to raise_error
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue