Skip to content

Commit

Permalink
added spec/support/vendor_config requirement for separating simulator…
Browse files Browse the repository at this point in the history
…/test config concern from gem
  • Loading branch information
gato-omega committed Jan 13, 2012
1 parent 55f248f commit 2189b8d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,3 +1,3 @@
.idea/
.bundle/

spec/support/vendor_config.rb
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -17,4 +17,5 @@ group :development do
gem 'hirb', '~> 0.6.0'
gem 'wirble', '~> 0.1.3'
gem 'wirb', '~> 0.4.1'
gem 'colorize', '~> 0.5.8'
end
2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -9,6 +9,7 @@ GEM
multi_json (~> 1.0)
awesome_print (1.0.1)
builder (3.0.0)
colorize (0.5.8)
hirb (0.6.0)
i18n (0.6.0)
macaddr (1.5.0)
Expand All @@ -30,6 +31,7 @@ DEPENDENCIES
activemodel (~> 3.1.0)
activesupport (~> 3.1.3)
awesome_print (= 1.0.1)
colorize (~> 0.5.8)
hirb (~> 0.6.0)
i18n (~> 0.6.0)
rake (= 0.8.7)
Expand Down
4 changes: 0 additions & 4 deletions lib/sage_pay.rb
@@ -1,5 +1,4 @@
require 'active_support/core_ext/class'
#require 'validatable'
require 'bigdecimal'
require 'net/https'
require 'uri'
Expand All @@ -14,9 +13,6 @@ module SagePay
require 'active_model/validator'
require 'active_model/validations'
require 'active_model/translation'
#require 'active_model/naming'

#require 'validatable-ext'

require 'sage_pay/uri_fixups'
require 'sage_pay/server/address'
Expand Down
9 changes: 2 additions & 7 deletions spec/integration/sage_pay/server_spec.rb
Expand Up @@ -3,15 +3,10 @@
if run_integration_specs?
describe SagePay::Server, "integration specs" do
before(:each) do
@vendor = "codescrumjairo"
#@notification_url = "https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorRegisterTx"
@notification_url = "http://190.146.87.50"

SagePay::Server.default_registration_options = {
:mode => :simulator,
:vendor => @vendor,
#:notification_url => "http://test.host/notification"
:notification_url => @notification_url
:vendor => SIMULATOR_VENDOR_NAME,
:notification_url => SIMULATOR_NOTIFICATION_URL
}
end

Expand Down
9 changes: 2 additions & 7 deletions spec/sage_pay/server_spec.rb
Expand Up @@ -4,15 +4,10 @@
describe ".payment" do
before(:each) do

@vendor = "codescrumpills"
#@notification_url = "https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorRegisterTx"
@notification_url = "https://test.sagepay.com/Simulator/VSPServerGateway.asp?Service=VendorRegisterTx"

SagePay::Server.default_registration_options = {
:mode => :test,
:vendor => @vendor,
#:notification_url => "http://test.host/notification"
:notification_url => @notification_url
:vendor => TEST_VENDOR_NAME,
:notification_url => TEST_NOTIFICATION_URL
}
end

Expand Down
28 changes: 28 additions & 0 deletions spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'spec/autorun'
require 'colorize'

$: << File.join(File.dirname(__FILE__), '..', 'lib')
require 'sage_pay'
Expand All @@ -8,6 +9,33 @@
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

puts "Loading vendor configuration...".green
errors = []
errors << "TEST_VENDOR_NAME is not set" unless defined? TEST_VENDOR_NAME
errors << "TEST_NOTIFICATION_URL is not set" unless defined? TEST_NOTIFICATION_URL
errors << "SIMULATOR_VENDOR_NAME is not set" unless defined? SIMULATOR_VENDOR_NAME
errors << "SIMULATOR_NOTIFICATION_URL is not set" unless defined? SIMULATOR_NOTIFICATION_URL

unless errors.empty?
puts "config file below, place custom settings in spec/support/vendor_config.rb as below>".cyan
example_file = <<EXAMPLE_FILE
#spec/support/vendor_config.rb
TEST_VENDOR_NAME = "testvendor"
TEST_NOTIFICATION_URL= "http://test.host/notification"
SIMULATOR_VENDOR_NAME = "your_simulator_account_vendor_name"
SIMULATOR_NOTIFICATION_URL= "your_simulator_site_notification_url"
EXAMPLE_FILE
puts example_file.light_white

puts errors.join("\n").red

raise "Vendor configuration not set properly, see the above example file"
end

Spec::Runner.configure do |config|
config.include(Factories)
config.include(ValidationMatchers)
Expand Down

0 comments on commit 2189b8d

Please sign in to comment.