test/test_helper.rb in active_fulfillment-2.1.9 vs test/test_helper.rb in active_fulfillment-3.0.0.pre2
- old
+ new
@@ -1,69 +1,44 @@
-#!/usr/bin/env ruby
-$:.unshift(File.dirname(__FILE__) + '/../lib')
+require 'bundler/setup'
-require 'rubygems'
-require 'bundler'
-Bundler.setup
+require 'active_fulfillment'
require 'minitest/autorun'
-require 'digest/md5'
-require 'active_fulfillment'
-require 'active_utils'
+require 'mocha/setup'
require 'timecop'
-require 'mocha/setup'
-
require 'logger'
-ActiveMerchant::Fulfillment::Service.logger = Logger.new(nil)
+ActiveFulfillment::Service.logger = Logger.new(nil)
-module Test
- module Unit
- class TestCase < MiniTest::Unit::TestCase
- include ActiveMerchant::Fulfillment
+# This makes sure that Minitest::Test exists when an older version of Minitest
+# (i.e. 4.x) is required by ActiveSupport.
+unless defined?(Minitest::Test)
+ Minitest::Test = MiniTest::Unit::TestCase
+end
- LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
- DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
+module ActiveFulfillment::Test
+ module Fixtures
+ LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_fulfillment/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
+ DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
- def all_fixtures
- @@fixtures ||= load_fixtures
- end
+ def fixtures(key)
+ data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
- def fixtures(key)
- data = all_fixtures[key] || raise(StandardError, "No fixture data was found for '#{key}'")
+ data.dup
+ end
- data.dup
- end
+ def xml_fixture(path) # where path is like 'usps/beverly_hills_to_ottawa_response'
+ File.read(File.join(File.dirname(__FILE__),'fixtures','xml',"#{path}.xml"))
+ end
- def load_fixtures
- file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
- yaml_data = YAML.load(File.read(file))
- symbolize_keys(yaml_data)
+ private
- yaml_data
- end
+ def all_fixtures
+ @@fixtures ||= load_fixtures
+ end
- def xml_fixture(path) # where path is like 'usps/beverly_hills_to_ottawa_response'
- open(File.join(File.dirname(__FILE__),'fixtures','xml',"#{path}.xml")) {|f| f.read}
- end
-
- def symbolize_keys(hash)
- return unless hash.is_a?(Hash)
-
- hash.symbolize_keys!
- hash.each{|k,v| symbolize_keys(v)}
- end
-
- def assert_raise(error)
- begin
- yield
- rescue => e
- flunk "Expected #{error} but nothing raised" if e.class != error
- end
- end
-
- def assert_nothing_raised
- yield
- end
+ def load_fixtures
+ file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
+ YAML.load(File.read(file)).deep_symbolize_keys
end
end
end