Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured the spec directory in order to split up the spec_helper …
…into provider-specific helpers, as well as some general cleanup of configuration and response files.
- Loading branch information
1 parent
0ec5fd1
commit b8dfd52
Showing
25 changed files
with
98 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
coverage | ||
rdoc | ||
pkg | ||
spec/fedex_credentials.yml | ||
spec/*_credentials.yml |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
key: your key | ||
password: your password | ||
account: your account username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
Shippinglogic::FedEx.options[:test] = true | ||
|
||
Spec::Runner.configure do |config| | ||
config.before(:each) do | ||
FakeWeb.clean_registry | ||
|
||
if File.exists?("#{SPEC_ROOT}/fedex/responses/_new.xml") | ||
raise "You have a new response in your response folder, you need to rename this before we can continue testing." | ||
end | ||
end | ||
|
||
def new_fedex | ||
Shippinglogic::FedEx.new(*fedex_credentials.values_at("key", "password", "account", "meter")) | ||
end | ||
|
||
def fedex_credentials | ||
return @fedex_credentials if defined?(@fedex_credentials) | ||
|
||
fedex_credentials_path = "#{SPEC_ROOT}/config/fedex_credentials.yml" | ||
|
||
unless File.exists?(fedex_credentials_path) | ||
raise "You need to add your own FedEx test credentials in spec/config/fedex_credentials.yml. See spec/config/fedex_credentials.example.yml for an example." | ||
end | ||
|
||
@fedex_credentials = YAML.load(File.read(fedex_credentials_path)) | ||
end | ||
|
||
def fedex_tracking_number | ||
"077973360403984" | ||
end | ||
|
||
def fedex_shipper | ||
{ | ||
:shipper_name => "Name", | ||
:shipper_title => "Title", | ||
:shipper_company_name => "Company", | ||
:shipper_phone_number => "2222222222", | ||
:shipper_email => "a@a.com", | ||
:shipper_streets => "260 Broadway", | ||
:shipper_city => "New York", | ||
:shipper_state => "NY", | ||
:shipper_postal_code => "10007", | ||
:shipper_country => "US" | ||
} | ||
end | ||
|
||
def fedex_recipient | ||
{ | ||
:recipient_name => "Name", | ||
:recipient_title => "Title", | ||
:recipient_department => "Department", | ||
:recipient_company_name => "Dallas City Hall", | ||
:recipient_phone_number => "2222222222", | ||
:recipient_email => "a@a.com", | ||
:recipient_streets => "1500 Marilla Street", | ||
:recipient_city => "Dallas", | ||
:recipient_state => "TX", | ||
:recipient_postal_code => "75201", | ||
:recipient_country => "US" | ||
} | ||
end | ||
|
||
def fedex_package | ||
{ | ||
:package_weight => 2, | ||
:package_length => 2, | ||
:package_width => 2, | ||
:package_height => 2 | ||
} | ||
end | ||
|
||
def use_response(key, options = {}) | ||
path = "#{SPEC_ROOT}/fedex/responses/#{key}.xml" | ||
if File.exists?(path) | ||
options[:content_type] ||= "text/xml" | ||
options[:body] ||= File.read(path) | ||
url = Shippinglogic::FedEx.options[:test_url] | ||
FakeWeb.register_uri(:post, url, options) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,12 @@ | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
|
||
require 'rubygems' | ||
require 'shippinglogic' | ||
require 'spec' | ||
require 'spec/autorun' | ||
begin; require 'ruby-debug'; rescue LoadError; end | ||
require 'fakeweb' | ||
require File.dirname(__FILE__) + "/lib/interceptor" | ||
|
||
Shippinglogic::FedEx.options[:test] = true | ||
|
||
Spec::Runner.configure do |config| | ||
config.before(:each) do | ||
FakeWeb.clean_registry | ||
|
||
if File.exists?(File.dirname(__FILE__) + "/responses/_new.xml") | ||
raise "You have a new response in your response folder, you need to rename this before we can continue testing." | ||
end | ||
end | ||
|
||
def new_fedex | ||
Shippinglogic::FedEx.new( | ||
fedex_credentials["key"], | ||
fedex_credentials["password"], | ||
fedex_credentials["account"], | ||
fedex_credentials["meter"] | ||
) | ||
end | ||
|
||
def fedex_credentials | ||
return @fedex_credentials if defined?(@fedex_credentials) | ||
|
||
fedex_credentials_path = File.dirname(__FILE__) + "/fedex_credentials.yml" | ||
|
||
if !File.exists?(fedex_credentials_path) | ||
raise "You need to add your own FedEx test credentials in spec/fedex_credentials.yml. See spec/fedex_credentials.example.yml for an example." | ||
end | ||
|
||
@fedex_credentials = YAML.load(File.read(fedex_credentials_path)) | ||
end | ||
|
||
def fedex_tracking_number | ||
"077973360403984" | ||
end | ||
|
||
def fedex_shipper | ||
{ | ||
:shipper_name => "Name", | ||
:shipper_title => "Title", | ||
:shipper_company_name => "Company", | ||
:shipper_phone_number => "2222222222", | ||
:shipper_email => "a@a.com", | ||
:shipper_streets => "260 Broadway", | ||
:shipper_city => "New York", | ||
:shipper_state => "NY", | ||
:shipper_postal_code => "10007", | ||
:shipper_country => "US" | ||
} | ||
end | ||
|
||
def fedex_recipient | ||
{ | ||
:recipient_name => "Name", | ||
:recipient_title => "Title", | ||
:recipient_department => "Department", | ||
:recipient_company_name => "Dallas City Hall", | ||
:recipient_phone_number => "2222222222", | ||
:recipient_email => "a@a.com", | ||
:recipient_streets => "1500 Marilla Street", | ||
:recipient_city => "Dallas", | ||
:recipient_state => "TX", | ||
:recipient_postal_code => "75201", | ||
:recipient_country => "US" | ||
} | ||
end | ||
|
||
def fedex_package | ||
{ | ||
:package_weight => 2, | ||
:package_length => 2, | ||
:package_width => 2, | ||
:package_height => 2 | ||
} | ||
end | ||
|
||
def use_response(key, options = {}) | ||
path = File.dirname(__FILE__) + "/responses/#{key}.xml" | ||
if File.exists?(path) | ||
options[:content_type] ||= "text/xml" | ||
options[:body] ||= File.read(path) | ||
FakeWeb.register_uri(:post, "https://gatewaybeta.fedex.com:443/xml", options) | ||
end | ||
end | ||
end | ||
SPEC_ROOT = File.dirname(__FILE__).freeze | ||
require SPEC_ROOT + "/lib/interceptor" |