Skip to content
Browse files

Removed Test::Unit tests in favor of RSpec.

  • Loading branch information...
1 parent 4b1914d commit 3e80f3293432f217bc9153a642de99f630cf3290 @travishaynes committed Jun 10, 2011
View
27 .gitignore
@@ -14,29 +14,4 @@ doc
# jeweler generated
pkg
-# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
-#
-# * Create a file at ~/.gitignore
-# * Include files you want ignored
-# * Run: git config --global core.excludesfile ~/.gitignore
-#
-# After doing this, these files will be ignored in all your git projects,
-# saving you from having to 'pollute' every project you touch with them
-#
-# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
-#
-# For MacOS:
-#
-#.DS_Store
-#
-# For TextMate
-#*.tmproj
-#tmtags
-#
-# For emacs:
-#*~
-#\#*
-#.\#*
-#
-# For vim:
-#*.swp
+log
View
2 .rspec
@@ -0,0 +1,2 @@
+--colour
+--format d
View
6 Gemfile
@@ -13,7 +13,11 @@ group :development do
gem 'rcov'
end
+group :development, :test do
+ gem 'rspec'
+ gem 'rspec-rails'
+end
+
group :test do
- gem 'shoulda'
gem 'fakeweb'
end
View
18 Gemfile.lock
@@ -32,6 +32,7 @@ GEM
builder (2.1.2)
crack (0.1.8)
curb (0.7.15)
+ diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
fakeweb (1.3.0)
@@ -76,12 +77,24 @@ GEM
thor (~> 0.14.4)
rake (0.8.7)
rcov (0.9.9)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rspec-rails (2.6.1)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.6.0)
savon (0.8.6)
builder (>= 2.1.2)
crack (~> 0.1.8)
gyoku (>= 0.3.0)
httpi (>= 0.7.8)
- shoulda (2.11.3)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
@@ -99,5 +112,6 @@ DEPENDENCIES
jeweler
rails (>= 3.0.0)
rcov
+ rspec
+ rspec-rails
savon
- shoulda
View
2 lib/fedex.rb
@@ -4,6 +4,8 @@ module Trackerific
class FedEx < Base
include Trackerific::SoapClient
+ TEST_TRACKING_NUMBERS = ['183689015000001']
+
def required_options
[:account, :meter, :key, :password]
end
View
0 log/test.log
No changes.
View
0 test/fixtures/fedex/success_response.xml → spec/fixtures/fedex_success_response.xml
File renamed without changes.
View
0 test/fixtures/ups/error_response.xml → spec/fixtures/ups_error_response.xml
File renamed without changes.
View
0 test/fixtures/ups/success_response.xml → spec/fixtures/ups_success_response.xml
File renamed without changes.
View
5 spec/lib/fedex_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Trackerific::FedEx do
+
+end
View
5 spec/lib/soap_client_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Trackerific::SoapClient do
+
+end
View
8 spec/lib/trackerific_spec.rb
@@ -0,0 +1,8 @@
+require 'spec_helper'
+
+describe Trackerific::Base do
+
+ it { should respond_to :track_package }
+ it { should respond_to :required_options }
+
+end
View
41 spec/lib/ups_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+require 'fakeweb'
+
+UPS_TRACK_URL = 'https://wwwcie.ups.com/ups.app/xml/Track'
+
+describe "Trackerific::UPS" do
+ include Fixtures
+
+ before(:all) do
+ @package_id = '1Z12345E0291980793'
+ @ups = Trackerific::UPS.new :key => 'testkey', :user_id => 'testuser', :password => 'secret'
+ end
+
+ describe "track_package" do
+ context "with a successful response from the server" do
+ before(:all) do
+ FakeWeb.register_uri(
+ :post,
+ UPS_TRACK_URL,
+ :body => load_fixture(:ups_success_response)
+ )
+ @valid_response = {
+ :package_id=>@package_id,
+ :summary=>"Mar 13 04:00 pm DELIVERED",
+ :details=>[]
+ }
+ end
+ specify { @ups.track_package(@package_id).should eq @valid_response }
+ end
+ context "with an error response from the server" do
+ before(:all) do
+ FakeWeb.register_uri(
+ :post,
+ UPS_TRACK_URL,
+ :body => load_fixture(:ups_error_response)
+ )
+ end
+ specify { lambda { @ups.track_package("invalid package id") }.should raise_error(Trackerific::Error) }
+ end
+ end
+end
View
5 spec/lib/usps_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Trackerific::USPS do
+
+end
View
10 spec/spec_helper.rb
@@ -0,0 +1,10 @@
+require 'rubygems'
+require 'bundler/setup'
+require 'trackerific'
+
+# load all the support files
+Dir["spec/support/**/*.rb"].each { |f| require File.expand_path(f) }
+require 'rspec/rails' # this has to be loaded after the support files
+RSpec.configure do |config|
+ config.mock_with :rspec
+end
View
16 spec/support/fixtures.rb
@@ -0,0 +1,16 @@
+module Fixtures
+
+ FIXTURES_PATH = "spec/fixtures/"
+
+ def load_fixture(name, ext = :xml)
+
+ file_name = File.join(FIXTURES_PATH, "#{name.to_s}.#{ext.to_s}")
+ f = File.open(file_name, 'r')
+ data = "";
+ f.lines.each { |line| data += line }
+ f.close
+ return data
+
+ end
+
+end
View
1 test/trackerific_test_app.rb → spec/support/trackerific_test_app.rb
@@ -22,5 +22,6 @@ class Application < Rails::Application
end
end
+puts "Loading Rails environment ..."
Rails.env = 'test'
Trackerific::Application.initialize!
View
32 test/helper.rb
@@ -1,32 +0,0 @@
-require 'rubygems'
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
-require 'test/unit'
-require 'shoulda'
-
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-$LOAD_PATH.unshift(File.dirname(__FILE__))
-require 'trackerific'
-require 'trackerific_test_app'
-
-class Test::Unit::TestCase
- def load_fixture(fixture_name)
- file_name = case fixture_name
- when :ups_success then File.join(File.dirname(__FILE__), 'fixtures', 'ups', 'success_response.xml')
- when :ups_error then File.join(File.dirname(__FILE__), 'fixtures', 'ups', 'error_response.xml')
- when :fedex_success then File.join(File.dirname(__FILE__), 'fixtures', 'fedex', 'success_response.xml')
- when :fedex_error then File.join(File.dirname(__FILE__), 'fixtures', 'fedex', 'error_response.xml')
- else raise "Invalid fixture name."
- end
- f = File.open(file_name, 'r')
- data = ""; f.lines.each do |line| data += line; end
- f.close
- return data
- end
-end
View
0 test/log/development.log
No changes.
View
0 test/log/test.log
No changes.
View
4 test/test_trackerific.rb
@@ -1,4 +0,0 @@
-require 'helper'
-
-class TestTrackerific < Test::Unit::TestCase
-end
View
30 test/test_ups.rb
@@ -1,30 +0,0 @@
-require 'helper'
-require 'fakeweb'
-require 'trackerific'
-
-class TestUPS < Test::Unit::TestCase
- UPS_TRACK_URL = 'https://wwwcie.ups.com/ups.app/xml/Track'
- context 'ups' do
- setup do
- @package_id = '1Z12345E0291980793'
- @ups = Trackerific::UPS.new :key => 'testkey', :user_id => 'testuser', :password => 'secret'
- end
-
- should "return a successful tracking response" do
- FakeWeb.register_uri(:post, UPS_TRACK_URL, :body => load_fixture(:ups_success))
- tracking_response = @ups.track_package(@package_id)
- assert_equal tracking_response, {
- :package_id=>"1Z12345E0291980793",
- :summary=>"Mar 13 04:00 pm DELIVERED",
- :details=>[] # TODO: add details to the success response
- }
- end
-
- should "raise a Trackerific:Error exception" do
- FakeWeb.register_uri(:post, UPS_TRACK_URL, :body => load_fixture(:ups_error))
- assert_raises Trackerific::Error do
- tracking_response = @ups.track_package(@package_id)
- end
- end
- end
-end

0 comments on commit 3e80f32

Please sign in to comment.
Something went wrong with that request. Please try again.