ship_me 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ class ProjectType
4
+ include ROXML
5
+
6
+ def initialize(attributes={})
7
+ self.scope = attributes[:scope]
8
+ end
9
+
10
+ xml_accessor :scope
11
+ end
12
+
13
+ class Project
14
+ include ROXML
15
+
16
+ def initialize
17
+ self.default_name = 'ShipMe'
18
+ end
19
+
20
+ xml_accessor :name
21
+ xml_accessor :hash
22
+ xml_accessor :array
23
+ xml_accessor :types, :as => [ProjectType]
24
+ xml_accessor :default_name
25
+ xml_accessor :type, :as => ProjectType, :from => 'ProjectType'
26
+ end
27
+
28
+ describe ROXML::AttributeInitializable do
29
+ it "should create not be initializable" do
30
+ Project.included_modules.should_not include(ROXML::AttributeInitializable)
31
+ Project.method(:initialize).arity.should == -1
32
+ end
33
+
34
+ describe "when initializable" do
35
+ before(:all) do
36
+ Project.class_eval { include ROXML::AttributeInitializable }
37
+ end
38
+
39
+ it "should be initializable" do
40
+ Project.included_modules.should include(ROXML::AttributeInitializable)
41
+ end
42
+
43
+ it "should initialize with attributes" do
44
+ @sut = Project.new({
45
+ :type => {
46
+ :scope => :daily
47
+ },
48
+ :types => [
49
+ {
50
+ :scope => :weekly
51
+ }
52
+ ],
53
+ :name => 'ShipMe',
54
+ :hash => {:a => :hash},
55
+ :array => [:an, :array]
56
+ })
57
+
58
+ @sut.type.should be_kind_of(ProjectType)
59
+ @sut.type.scope.should == :daily
60
+ @sut.name.should == 'ShipMe'
61
+ @sut.hash.should == {:a => :hash}
62
+ @sut.array.should == [:an, :array]
63
+ @sut.types.first.should be_kind_of(ProjectType)
64
+ @sut.types.first.scope :weekly
65
+ @sut.default_name.should == 'ShipMe'
66
+ @sut.to_xml
67
+ end
68
+
69
+ it "should initialize with attributes overriding defaults" do
70
+ @sut = Project.new({
71
+ :type => {
72
+ :scope => :daily
73
+ },
74
+ :default_name => 'ShipToMe'
75
+ })
76
+
77
+ @sut.default_name.should == 'ShipToMe'
78
+ end
79
+
80
+ it "should initialize with nil attributes" do
81
+ lambda {
82
+ @sut = Project.new(nil)
83
+ }.should_not raise_error
84
+
85
+ @sut.default_name.should == 'ShipMe'
86
+ end
87
+
88
+ it "should initialize with nil values" do
89
+ lambda {
90
+ @sut = Project.new({:type => nil})
91
+ }.should_not raise_error
92
+
93
+ @sut.default_name.should == 'ShipMe'
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,110 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ShipMe do
4
+ context "with delete shipment request template" do
5
+ before do
6
+ ShipMe.template :delete, ShipMe::FedEx::DeleteShipmentRequest do
7
+ {
8
+ :key => "1111",
9
+ :password => '2222',
10
+ :account_number => '3333',
11
+ :meter_number => '4444'
12
+ }
13
+ end
14
+ end
15
+
16
+ it "should initialize with defaults" do
17
+ ShipMe.templates[:delete].make.tap do |t|
18
+ t.should be_kind_of(ShipMe::FedEx::DeleteShipmentRequest)
19
+ t.key.should == '1111'
20
+ t.password.should == '2222'
21
+ t.account_number.should == '3333'
22
+ t.meter_number.should == '4444'
23
+ end
24
+ end
25
+ end
26
+
27
+ context "with process shipment request template" do
28
+ before do
29
+ ShipMe.template :process, ShipMe::FedEx::ProcessShipmentRequest do
30
+ {
31
+ :key => "1111",
32
+ :password => '2222',
33
+ :account_number => '3333',
34
+ :meter_number => '4444',
35
+ :requested_shipment => {
36
+ :ship_timestamp => "2010-08-03T14:46:01-07:00",
37
+ :dropoff_type => ShipMe::FedEx::DropoffType::REGULAR_PICKUP,
38
+ :service_type => ShipMe::FedEx::ServiceType::FEDEX_GROUND,
39
+ :packaging_type => ShipMe::FedEx::PackagingType::YOUR_PACKAGING,
40
+ :shipper => {
41
+ :contact => {
42
+ :person_name => 'Henry Hsu',
43
+ :company_name => 'Photo USA Corporation',
44
+ :phone_number => '4087359900'
45
+ },
46
+ :address => {
47
+ :street_line => '1133 Sonora Ct.',
48
+ :city => 'Sunnyvale',
49
+ :state_or_province_code => 'CA',
50
+ :postal_code => '94086',
51
+ :country_code => 'US'
52
+ }
53
+ },
54
+ :recipient => ShipMe::FedEx::Party.new(
55
+ :contact => ShipMe::FedEx::Contact.new(
56
+ :person_name => 'Henry Hsu',
57
+ :company_name => 'Photo USA Corporation',
58
+ :phone_number => '4087359900'
59
+ ),
60
+ :address => ShipMe::FedEx::Address.new(
61
+ :street_line => recipient_street_line,
62
+ :street_line_2 => 'Building #2',
63
+ :city => 'Sunnyvale',
64
+ :state_or_province_code => 'CA',
65
+ :postal_code => '94086',
66
+ :country_code => 'US'
67
+ )
68
+ ),
69
+ :shipping_charges_payment => {
70
+ :payment_type => ShipMe::FedEx::PaymentType::SENDER,
71
+ :payor => {
72
+ :account_number => '3333',
73
+ :country_code => 'US'
74
+ }
75
+ },
76
+ :label_specification => {
77
+ :label_format_type => ShipMe::FedEx::LabelFormatType::COMMON2D,
78
+ :image_type => ShipMe::FedEx::ShippingDocumentImageType::PNG,
79
+ :label_stock_type => ShipMe::FedEx::LabelStockType::PAPER_4X6
80
+ },
81
+ :rate_request_types => [ShipMe::FedEx::RateRequestType::LIST],
82
+ :package_count => 1,
83
+ :package_detail => ShipMe::FedEx::RequestedPackageDetailType::INDIVIDUAL_PACKAGES,
84
+ :requested_package_line_items => [
85
+ ShipMe::FedEx::RequestedPackageLineItem.new(
86
+ :weight => {
87
+ :units => ShipMe::FedEx::WeightUnits::LB,
88
+ :value => '33'
89
+ },
90
+ :dimensions => {
91
+ :length => 14,
92
+ :width => 14,
93
+ :height => 14,
94
+ :units => ShipMe::FedEx::LinearUnits::IN
95
+ }
96
+ )
97
+ ]
98
+ }
99
+ }
100
+ end
101
+ end
102
+
103
+ it "should initialize with defaults" do
104
+ ShipMe.templates[:process].make(:recipient_street_line => 'The Address').tap do |t|
105
+ t.should be_kind_of(ShipMe::FedEx::ProcessShipmentRequest)
106
+ t.requested_shipment.recipient.address.street_line.should == 'The Address'
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,16 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require "rubygems"
4
+ require "bundler"
5
+ Bundler.setup
6
+
7
+ require 'ship_me'
8
+ require 'spec'
9
+ require 'spec/autorun'
10
+
11
+ Spec::Runner.configure do |config|
12
+ config.mock_with :mocha
13
+
14
+ require 'fakeweb'
15
+ FakeWeb.allow_net_connect = false
16
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ship_me
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 0
10
+ version: 0.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Henry Hsu
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-17 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: roxml
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 3
32
+ - 1
33
+ - 5
34
+ version: 3.1.5
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: activesupport
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 2
48
+ - 3
49
+ - 8
50
+ version: 2.3.8
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: active_merchant
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 13
76
+ segments:
77
+ - 1
78
+ - 2
79
+ - 9
80
+ version: 1.2.9
81
+ type: :development
82
+ version_requirements: *id004
83
+ description: Just ship me. No fuss FedEx integration for Ruby
84
+ email: henry@qlane.com
85
+ executables: []
86
+
87
+ extensions: []
88
+
89
+ extra_rdoc_files:
90
+ - LICENSE
91
+ - README.rdoc
92
+ files:
93
+ - .autotest
94
+ - .document
95
+ - .gitignore
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - LICENSE
99
+ - README.rdoc
100
+ - Rakefile
101
+ - VERSION
102
+ - lib/roxml/attribute_initializable.rb
103
+ - lib/ship_me.rb
104
+ - lib/ship_me/carriers/fed_ex.rb
105
+ - lib/ship_me/carriers/fed_ex/element.rb
106
+ - lib/ship_me/carriers/fed_ex/types.rb
107
+ - lib/ship_me/posts_data.rb
108
+ - lib/ship_me/restricted_enumeration.rb
109
+ - lib/ship_me/template.rb
110
+ - ship_me.gemspec
111
+ - spec/carriers/fed_ex_spec.rb
112
+ - spec/cases/delete_shipment.rb
113
+ - spec/cases/pending_shipment.rb
114
+ - spec/cases/process_shipment.rb
115
+ - spec/cases/process_shipment_template.rb
116
+ - spec/fixtures/fed_ex/delete_request.xml
117
+ - spec/fixtures/fed_ex/delete_response.xml
118
+ - spec/fixtures/fed_ex/deleted_response.xml
119
+ - spec/fixtures/fed_ex/pending_request.xml
120
+ - spec/fixtures/fed_ex/pending_response.xml
121
+ - spec/fixtures/fed_ex/process_request.xml
122
+ - spec/fixtures/fed_ex/process_response.xml
123
+ - spec/restricted_enumeration_spec.rb
124
+ - spec/roxml/attribute_initializable_spec.rb
125
+ - spec/ship_me_spec.rb
126
+ - spec/spec.opts
127
+ - spec/spec_helper.rb
128
+ has_rdoc: true
129
+ homepage: http://github.com/hsume2/ship_me
130
+ licenses: []
131
+
132
+ post_install_message:
133
+ rdoc_options:
134
+ - --charset=UTF-8
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ hash: 3
152
+ segments:
153
+ - 0
154
+ version: "0"
155
+ requirements: []
156
+
157
+ rubyforge_project:
158
+ rubygems_version: 1.3.7
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Just ship me. No fuss.
162
+ test_files:
163
+ - spec/carriers/fed_ex_spec.rb
164
+ - spec/cases/delete_shipment.rb
165
+ - spec/cases/pending_shipment.rb
166
+ - spec/cases/process_shipment.rb
167
+ - spec/cases/process_shipment_template.rb
168
+ - spec/restricted_enumeration_spec.rb
169
+ - spec/roxml/attribute_initializable_spec.rb
170
+ - spec/ship_me_spec.rb
171
+ - spec/spec_helper.rb