Skip to content

Commit

Permalink
Start of feature tests #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Willianvdv committed Mar 18, 2014
1 parent 718e77c commit d831597
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ gem 'coveralls', require: false
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable'
gem 'spree', github: 'spree/spree', branch: '2-2-stable'

group :test do
gem 'capybara', '~> 2.1'
gem 'database_cleaner', '~> 1.0.1'
gem 'selenium-webdriver', '~> 2.35'
gem 'poltergeist', '1.5.0'
end

gemspec
Empty file.
1 change: 0 additions & 1 deletion app/assets/javascripts/store/spree_omnikassa.js

This file was deleted.

Empty file.
3 changes: 0 additions & 3 deletions app/assets/stylesheets/store/spree_omnikassa.css

This file was deleted.

6 changes: 6 additions & 0 deletions lib/spree_omnikassa/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :omnikassa_payment_method, class: Spree::BillingIntegration::Omnikassa do
name 'Omnikassa'
environment 'test'
end
end
38 changes: 38 additions & 0 deletions spec/features/frontend/checkout_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe "Checkout", js: true do
let!(:country) { create(:country, :states_required => true) }
let!(:state) { create(:state, :country => country) }
let!(:shipping_method) { create(:shipping_method) }
let!(:stock_location) { create(:stock_location) }
let!(:mug) { create(:product, :name => "RoR Mug") }
let!(:payment_method) { create(:check_payment_method) }
let!(:zone) { create(:zone) }

let!(:omnikassa_payment_method) { create(:omnikassa_payment_method) }

describe 'pay with omnikassa' do
before do
order = OrderWalkthrough.up_to(:delivery)
user = create(:user)
order.user = user
order.update!

Spree::CheckoutController.any_instance.stub(:current_order => order)
Spree::CheckoutController.any_instance.stub(:try_spree_current_user => user)
end

it 'redirects to omnikassa' do
visit spree.checkout_state_path(:payment)
#select "United States of America", :from => "#{address}_country_id"
choose('Omnikassa')
click_button "Save and Continue"

sleep 10
end
end

end


#order[payments_attributes][][payment_method_id]
22 changes: 17 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@
require 'spree/testing_support/controller_requests'
require 'spree/testing_support/authorization_helpers'
require 'spree/testing_support/url_helpers'
require 'spree/testing_support/order_walkthrough'

# Requires factories defined in lib/spree_omnikassa/factories.rb
require 'spree_omnikassa/factories'

if ENV['WEBDRIVER'] == 'accessible'
require 'capybara/accessible'
Capybara.javascript_driver = :accessible
elsif ENV['WEBDRIVER'] == 'selenium'
Capybara.javascript_driver = :selenium
else
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
end

RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include Devise::TestHelpers, :type => :controller
Expand Down Expand Up @@ -83,19 +94,20 @@
config.include Spree::TestingSupport::Preferences
config.include Spree::TestingSupport::UrlHelpers
config.include Spree::TestingSupport::ControllerRequests

config.fail_fast = ENV['FAIL_FAST'] || false
end

shared_context 'omnikassa' do
before do
reset_spree_preferences do |config|
config.payment_methods << Spree::BillingIntegration::Omnikassa
config.currency = "EUR"
config.omnikassa_merchant_id = '1337'
config.omnikassa_url = 'https://payment-webinit.simu.omnikassa.rabobank.nl/paymentServlet'
config.omnikassa_merchant_id = '002020000000001'
config.omnikassa_secret_key = '002020000000001_KEY1'
config.omnikassa_key_version = '1'
config.omnikassa_transaction_reference_prefix = 'PREFIX'
config.omnikassa_key_version = '7'
config.omnikassa_secret_key = 'SECRET'
end
end
end

0 comments on commit d831597

Please sign in to comment.