run stripe feature test only if key is set

This commit is contained in:
Rishabh Saxena 2016-08-17 23:57:40 +05:30
parent cc09dd76ba
commit 4152cb242c
2 changed files with 31 additions and 27 deletions

View file

@ -33,6 +33,7 @@ feature Registration do
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)
if Rails.application.secrets.stripe_publishable_key
find('.stripe-button-el').click find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last stripe_iframe = all('iframe[name=stripe_checkout_app]').last
@ -49,6 +50,7 @@ feature Registration do
expect(current_path).to eq(conference_conference_registration_path(conference.short_title)) expect(current_path).to eq(conference_conference_registration_path(conference.short_title))
expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true expect(page.has_content?("2 #{ticket.title} Tickets for $ 10")).to be true
end end
end
scenario 'purchases ticket but payment fails', feature: true, js: true do scenario 'purchases ticket but payment fails', feature: true, js: true do
visit root_path visit root_path
@ -67,6 +69,7 @@ feature Registration do
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)
if Rails.application.secrets.stripe_publishable_key
find('.stripe-button-el').click find('.stripe-button-el').click
stripe_iframe = all('iframe[name=stripe_checkout_app]').last stripe_iframe = all('iframe[name=stripe_checkout_app]').last
@ -86,3 +89,4 @@ feature Registration do
end end
end end
end end
end

View file

@ -1,6 +1,6 @@
# Mock external requests to youtube # Mock external requests to youtube
require 'webmock/rspec' require 'webmock/rspec'
WebMock.disable_net_connect!(allow_localhost: true, allow: %r{stripe.com}) WebMock.disable_net_connect!(allow_localhost: true, allow: /stripe.com/)
RSpec.configure do |config| RSpec.configure do |config|
config.before(:each) do config.before(:each) do