shipping 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,23 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
  class BaseTest < Test::Unit::TestCase
3
3
  def setup
4
- @ship = Shipping::Base.new :zip => 97202, :state => "OR", :sender_zip => 10001, :sender_state => "New York", :weight => 2
4
+ @ship = Shipping::Base.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
5
11
  end
6
-
12
+
7
13
  def test_ups
8
- ups = @ship.ups
14
+ ups = @ship.ups
9
15
  assert_instance_of Shipping::UPS, ups
10
16
  assert_equal ups.zip, @ship.zip
11
17
  end
12
18
 
13
19
  def test_fedex
14
- fedex = @ship.fedex
20
+ fedex = @ship.fedex
15
21
  assert_instance_of Shipping::FedEx, fedex
16
22
  assert_equal fedex.zip, @ship.zip
17
23
  end
@@ -1,38 +1,71 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
  class FedExTest < Test::Unit::TestCase
3
3
  def setup
4
- @ship = Shipping::FedEx.new :zip => 97202, :state => "OR", :sender_zip => 10001, :sender_state => "New York", :weight => 2
4
+ @ship = Shipping::FedEx.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
11
+
12
+ # use demo environment for tests
13
+ @ship.fedex_url = 'https://gatewaybeta.fedex.com/GatewayDC'
5
14
  end
6
-
15
+
7
16
  def test_price
8
- assert_in_delta 5.00, @ship.price, 1
17
+ assert_in_delta 5.80, @ship.price, 1
9
18
  end
10
19
 
11
20
  def test_discount_price
12
- assert_in_delta 5.00, @ship.discount_price, 1
13
- assert @ship.discount_price < @ship.price
21
+ assert_in_delta 5.80, @ship.discount_price, 1
22
+ assert @ship.discount_price < @ship.price
14
23
  end
15
24
 
16
25
  def test_fails
17
- ship = Shipping::FedEx.new :zip => 97202, :weight => 2
18
- assert_raise(Shipping::ShippingError) { ship.price }
26
+ ship = Shipping::FedEx.new :zip => 97202, :weight => 2
27
+ assert_raise(Shipping::ShippingError) { ship.price }
19
28
  end
20
29
 
21
30
  def test_label
22
- @ship.name = "Package Receiver"
23
- @ship.phone = "555-555-5555"
24
- @ship.email = "lucas@rufy.com"
25
- @ship.address = "Some address"
26
- @ship.city = "Portland"
27
-
28
- @ship.sender_name = "Package Sender"
29
- @ship.sender_phone = "333-333-3333"
30
- @ship.sender_email = "john@doe.com"
31
- @ship.sender_address = "Ok old address"
32
- @ship.sender_city = "New York"
33
-
34
- response = nil
35
- # assert_nothing_raised { response = @ship.label }
36
- # assert_equal 'PackageSen', response.image_userid
31
+ @ship.name = "Package Receiver"
32
+ @ship.phone = "555-555-5555"
33
+ @ship.email = "lucas@rufy.com"
34
+ @ship.address = "Some address"
35
+ @ship.city = "Portland"
36
+
37
+ @ship.sender_name = "Package Sender"
38
+ @ship.sender_phone = "333-333-3333"
39
+ @ship.sender_email = "john@doe.com"
40
+ @ship.sender_address = "Ok old address"
41
+ @ship.sender_city = "New York"
42
+
43
+ assert_nothing_raised { @label = @ship.label }
44
+ assert_not_nil @label.tracking_number
45
+ assert_not_nil @label.image.path
46
+ #assert_equal `file -i -b #{@label.image.path}`, "image/png\n"
47
+ end
48
+
49
+ def test_void
50
+ @ship.name = "Package Receiver"
51
+ @ship.phone = "555-555-5555"
52
+ @ship.email = "lucas@rufy.com"
53
+ @ship.address = "Some address"
54
+ @ship.city = "Portland"
55
+
56
+ @ship.sender_name = "Package Sender"
57
+ @ship.sender_phone = "333-333-3333"
58
+ @ship.sender_email = "john@doe.com"
59
+ @ship.sender_address = "Ok old address"
60
+ @ship.sender_city = "New York"
61
+
62
+ assert_nothing_raised { @label = @ship.label }
63
+
64
+ assert @ship.void(@label.tracking_number)
65
+ end
66
+
67
+ def test_void_fail
68
+ # made up tracking number
69
+ assert_raise(Shipping::ShippingError) { @ship.void('470012923511666') }
37
70
  end
38
71
  end
data/test/ups/ups_test.rb CHANGED
@@ -1,16 +1,72 @@
1
1
  require File.dirname(__FILE__) + '/../test_helper'
2
2
  class UpsTest < Test::Unit::TestCase
3
3
  def setup
4
- @ship = Shipping::UPS.new :zip => 97202, :state => "OR", :sender_zip => 10001, :sender_state => "New York", :weight => 2
4
+ @ship = Shipping::UPS.new(
5
+ :zip => 97202,
6
+ :state => "OR",
7
+ :sender_zip => 10001,
8
+ :sender_state => "New York",
9
+ :weight => 2
10
+ )
11
+
12
+ # use demo environment for tests
13
+ @ship.ups_url = 'https://wwwcie.ups.com/ups.app/xml'
5
14
  end
6
-
15
+
7
16
  def test_price
8
- assert_in_delta 8.82, @ship.price, 1
17
+ # price is subject to account details, it seems?
18
+ assert_in_delta 5.80, @ship.price, 1
9
19
  end
10
20
 
11
21
  def test_valid_address
12
- assert !@ship.valid_address?
13
- @ship.city = "Portland"
14
- assert @ship.valid_address?
22
+ assert !@ship.valid_address?
23
+ @ship.city = "Portland"
24
+ assert @ship.valid_address?
25
+ end
26
+
27
+ def test_label
28
+ @ship.name = "Package Receiver"
29
+ @ship.company = "Package Receiver Company"
30
+ @ship.phone = "555-555-5555"
31
+ @ship.email = "lucas@rufy.com"
32
+ @ship.address = "Some address"
33
+ @ship.city = "Portland"
34
+
35
+ @ship.sender_name = "Package Sender"
36
+ @ship.sender_company = "Package Sender Company"
37
+ @ship.sender_phone = "333-333-3333"
38
+ @ship.sender_email = "john@doe.com"
39
+ @ship.sender_address = "Ok old address"
40
+ @ship.sender_city = "New York"
41
+
42
+ assert_nothing_raised { @label = @ship.label }
43
+ assert_not_nil @label.tracking_number
44
+ assert_not_nil @label.image.path
45
+ #assert_equal `file -i -b #{@label.image.path}`, "image/gif\n"
46
+ end
47
+
48
+ def test_void
49
+ @ship.name = "Package Receiver"
50
+ @ship.company = "Package Receiver Company"
51
+ @ship.phone = "555-555-5555"
52
+ @ship.email = "lucas@rufy.com"
53
+ @ship.address = "Some address"
54
+ @ship.city = "Portland"
55
+
56
+ @ship.sender_name = "Package Sender"
57
+ @ship.sender_company = "Package Sender Company"
58
+ @ship.sender_phone = "333-333-3333"
59
+ @ship.sender_email = "john@doe.com"
60
+ @ship.sender_address = "Ok old address"
61
+ @ship.sender_city = "New York"
62
+
63
+ assert_nothing_raised { @label = @ship.label }
64
+
65
+ assert @ship.void(@label.tracking_number)
66
+ end
67
+
68
+ def test_void_fail
69
+ # Tracking number from certification process; Time for voiding has expired
70
+ assert_raise(Shipping::ShippingError) { @ship.void('1Z12345E0392508488') }
15
71
  end
16
72
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: shipping
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.3.0
7
- date: 2005-09-24
6
+ version: 1.5.0
7
+ date: 2007-01-02 00:00:00 -08:00
8
8
  summary: A general shipping module to find out the shipping prices via UPS or FedEx.
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: lucas@rufy.com
12
12
  homepage: http://shipping.rufy.com/
13
13
  rubyforge_project:
@@ -18,46 +18,52 @@ bindir: bin
18
18
  has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
27
29
  authors:
28
- - Lucas Carlson
30
+ - Lucas Carlson
29
31
  files:
30
- - lib/extensions.rb
31
- - lib/shipping
32
- - lib/shipping.rb
33
- - lib/shipping/base.rb
34
- - lib/shipping/fedex.rb
35
- - lib/shipping/ups.rb
36
- - test/base
37
- - test/fedex
38
- - test/test_helper.rb
39
- - test/ups
40
- - test/base/base_test.rb
41
- - test/fedex/fedex_test.rb
42
- - test/ups/ups_test.rb
43
- - LICENSE
44
- - Rakefile
45
- - README
32
+ - lib/extensions.rb
33
+ - lib/shipping
34
+ - lib/shipping.rb
35
+ - lib/shipping/base.rb
36
+ - lib/shipping/fedex.rb
37
+ - lib/shipping/ups.rb
38
+ - test/base
39
+ - test/fedex
40
+ - test/test_helper.rb
41
+ - test/ups
42
+ - test/base/base_test.rb
43
+ - test/fedex/fedex_test.rb
44
+ - test/ups/ups_test.rb
45
+ - LICENSE
46
+ - Rakefile
47
+ - README
46
48
  test_files: []
49
+
47
50
  rdoc_options: []
51
+
48
52
  extra_rdoc_files: []
53
+
49
54
  executables: []
55
+
50
56
  extensions: []
57
+
51
58
  requirements:
52
- - An xml-builder library.
59
+ - An xml-builder library.
53
60
  dependencies:
54
- - !ruby/object:Gem::Dependency
55
- name: builder
56
- version_requirement:
57
- version_requirements: !ruby/object:Gem::Version::Requirement
58
- requirements:
59
- -
60
- - ">="
61
- - !ruby/object:Gem::Version
62
- version: 1.2.0
63
- version:
61
+ - !ruby/object:Gem::Dependency
62
+ name: builder
63
+ version_requirement:
64
+ version_requirements: !ruby/object:Gem::Version::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.2.0
69
+ version: