ruby-ecomm-client 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +12 -0
- data/fixtures/vcr_cassettes/account_info/default.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/account_info/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/default.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/downgrade/unknown/target_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/express_checkout/configured.yml +40 -0
- data/fixtures/vcr_cassettes/express_checkout/unknown.yml +40 -0
- data/fixtures/vcr_cassettes/transitions/default/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/many.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/one.yml +42 -0
- data/fixtures/vcr_cassettes/transitions/unknown/source_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/default.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/upgrade/unknown/target_tree_id.yml +42 -0
- data/lib/ruby-ecomm-client.rb +10 -0
- data/lib/ruby-ecomm-client/client.rb +148 -0
- data/lib/ruby-ecomm-client/converter.rb +45 -0
- data/lib/ruby-ecomm-client/error.rb +12 -0
- data/lib/ruby-ecomm-client/version.rb +3 -0
- data/lib/ruby-ecomm-client/wsdl/manager.wsdl +296 -0
- data/lib/ruby-ecomm-client/wsdl/profile.wsdl +66 -0
- data/lib/ruby-ecomm-client/wsdl/purchase.wsdl +74 -0
- data/ruby-ecomm-client.gemspec +30 -0
- data/script/cibuild +10 -0
- data/spec/ruby-ecomm-client/client_spec.rb +297 -0
- data/spec/ruby-ecomm-client/converter_spec.rb +96 -0
- data/spec/ruby-ecomm-client/error_spec.rb +39 -0
- data/spec/spec_helper.rb +21 -0
- metadata +237 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestResponder
|
4
|
+
include ::ResponseConverter
|
5
|
+
end
|
6
|
+
|
7
|
+
describe ResponseConverter do
|
8
|
+
before do
|
9
|
+
@responder = TestResponder.new
|
10
|
+
end
|
11
|
+
|
12
|
+
context "#CONVERTER" do
|
13
|
+
it "snakecase" do
|
14
|
+
ResponseConverter::TAG_CONVERTER.call('TestSnake').should eq(:test_snake)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "remove @" do
|
18
|
+
ResponseConverter::TAG_CONVERTER.call('@test').should eq(:test)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "remove unified_" do
|
22
|
+
ResponseConverter::TAG_CONVERTER.call('unified_test').should eq(:test)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "remove current_" do
|
26
|
+
ResponseConverter::TAG_CONVERTER.call('current_test').should eq(:test)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "all together" do
|
30
|
+
ResponseConverter::TAG_CONVERTER.call('@CurrentUnifiedTest').should eq(:test)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "#convert_value" do
|
35
|
+
it "convert lower boolean string" do
|
36
|
+
@responder.convert_value('true').should eq(true)
|
37
|
+
@responder.convert_value('false').should eq(false)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "convert title boolean string" do
|
41
|
+
@responder.convert_value('True').should eq(true)
|
42
|
+
@responder.convert_value('false').should eq(false)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "convert upper boolean string" do
|
46
|
+
@responder.convert_value('TRUE').should eq(true)
|
47
|
+
@responder.convert_value('FALSE').should eq(false)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "convert float string" do
|
51
|
+
value = @responder.convert_value('-1.0')
|
52
|
+
value.class.should eq(Float)
|
53
|
+
value.should eq(-1.0)
|
54
|
+
|
55
|
+
value = @responder.convert_value('9.09')
|
56
|
+
value.class.should eq(Float)
|
57
|
+
value.should eq(9.09)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "convert integer string" do
|
61
|
+
value = @responder.convert_value('-324')
|
62
|
+
value.class.should eq(Fixnum)
|
63
|
+
value.should eq(-324)
|
64
|
+
|
65
|
+
value = @responder.convert_value('537')
|
66
|
+
value.class.should eq(Fixnum)
|
67
|
+
value.should eq(537)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "otherwise return same" do
|
71
|
+
@responder.convert_value('unknown').should eq('unknown')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "#convert_response" do
|
76
|
+
it "convert each Hash value" do
|
77
|
+
@responder.convert_response({ :a => '-1', :b => '2.0', :c => 'True', :d => 'other' }).should eq({ :a => -1, :b => 2.0, :c => true, :d => 'other' })
|
78
|
+
end
|
79
|
+
|
80
|
+
it "convert each nested Array value" do
|
81
|
+
@responder.convert_response({ :a => '-1', :b => ['2.0', 'True', 'other'] }).should eq({ :a => -1, :b => [2.0, true, 'other' ] })
|
82
|
+
end
|
83
|
+
|
84
|
+
it "convert each nested Hash value" do
|
85
|
+
@responder.convert_response({ :a => '-1', :b => { :aa => '2.0', :bb => 'True', :cc => 'other' } }).should eq({ :a => -1, :b => { :aa => 2.0, :bb => true, :cc => 'other' } })
|
86
|
+
end
|
87
|
+
|
88
|
+
it "convert each Hash value in each Array entry" do
|
89
|
+
@responder.convert_response([{ :a => '-1', :b => '2.0', :c => 'True' }, { :a => 'False', :b => '5.4', :c => '-332.78' }]).should eq([{ :a => -1, :b => 2.0, :c => true }, { :a => false, :b => 5.4, :c => -332.78 }])
|
90
|
+
end
|
91
|
+
|
92
|
+
it "otherwise return same" do
|
93
|
+
@responder.convert_response('unknown').should eq('unknown')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RubyEcommError do
|
4
|
+
before do
|
5
|
+
@result_code = -1
|
6
|
+
@request_result = -2
|
7
|
+
@error = RubyEcommError.new(@result_code, @request_result)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "#initialize" do
|
11
|
+
it "require result_code non-nil" do
|
12
|
+
expect { RubyEcommError.new(nil) }.to raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "require result_code non-blank" do
|
16
|
+
expect { RubyEcommError.new('') }.to raise_error(ArgumentError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "honor result_code" do
|
20
|
+
@error.result_code.should eq(@result_code)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "put result_code in message" do
|
24
|
+
@error.message.should include(@result_code.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "require request_result non-blank" do
|
28
|
+
expect { RubyEcommError.new('-100', '') }.to raise_error(ArgumentError)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "honor request_result" do
|
32
|
+
@error.request_result.should eq(@request_result)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "put request_result in message" do
|
36
|
+
@error.message.should include(@request_result.to_s)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'ruby-ecomm-client' # and any other gems you need
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'vcr'
|
10
|
+
|
11
|
+
VCR.configure do |c|
|
12
|
+
c.cassette_library_dir = 'fixtures/vcr_cassettes'
|
13
|
+
c.hook_into :fakeweb
|
14
|
+
end
|
15
|
+
|
16
|
+
if [:qa, :production].include?(RubyEcommClient::Client.environment)
|
17
|
+
VCR.turn_off!(:ignore_cassettes => true)
|
18
|
+
FakeWeb.allow_net_connect = true
|
19
|
+
else
|
20
|
+
FakeWeb.allow_net_connect = false
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-ecomm-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Shelby Sanders
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2014-03-26 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - "="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 73
|
27
|
+
segments:
|
28
|
+
- 10
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
version: 10.1.1
|
32
|
+
type: :development
|
33
|
+
requirement: *id001
|
34
|
+
prerelease: false
|
35
|
+
name: rake
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
requirement: *id002
|
48
|
+
prerelease: false
|
49
|
+
name: ci_reporter
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
requirement: *id003
|
62
|
+
prerelease: false
|
63
|
+
name: fakeweb
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :development
|
75
|
+
requirement: *id004
|
76
|
+
prerelease: false
|
77
|
+
name: gemfury
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :development
|
89
|
+
requirement: *id005
|
90
|
+
prerelease: false
|
91
|
+
name: rcov
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
requirement: *id006
|
104
|
+
prerelease: false
|
105
|
+
name: rspec
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
type: :development
|
117
|
+
requirement: *id007
|
118
|
+
prerelease: false
|
119
|
+
name: vcr
|
120
|
+
- !ruby/object:Gem::Dependency
|
121
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - "="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 23
|
127
|
+
segments:
|
128
|
+
- 1
|
129
|
+
- 5
|
130
|
+
- 10
|
131
|
+
version: 1.5.10
|
132
|
+
type: :runtime
|
133
|
+
requirement: *id008
|
134
|
+
prerelease: false
|
135
|
+
name: nokogiri
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
version_requirements: &id009 !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
|
+
type: :runtime
|
147
|
+
requirement: *id009
|
148
|
+
prerelease: false
|
149
|
+
name: savon
|
150
|
+
description: Easy access to the e-commerce web services via Ruby
|
151
|
+
email:
|
152
|
+
- ssanders@godaddy.com
|
153
|
+
executables: []
|
154
|
+
|
155
|
+
extensions: []
|
156
|
+
|
157
|
+
extra_rdoc_files: []
|
158
|
+
|
159
|
+
files:
|
160
|
+
- .gitignore
|
161
|
+
- .ruby-version
|
162
|
+
- Gemfile
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.md
|
165
|
+
- Rakefile
|
166
|
+
- fixtures/vcr_cassettes/account_info/default.yml
|
167
|
+
- fixtures/vcr_cassettes/account_info/unknown/resource_id.yml
|
168
|
+
- fixtures/vcr_cassettes/account_info/unknown/resource_type.yml
|
169
|
+
- fixtures/vcr_cassettes/account_info/unknown/source_tree_id.yml
|
170
|
+
- fixtures/vcr_cassettes/downgrade/default.yml
|
171
|
+
- fixtures/vcr_cassettes/downgrade/noop.yml
|
172
|
+
- fixtures/vcr_cassettes/downgrade/unknown/resource_id.yml
|
173
|
+
- fixtures/vcr_cassettes/downgrade/unknown/resource_type.yml
|
174
|
+
- fixtures/vcr_cassettes/downgrade/unknown/target_tree_id.yml
|
175
|
+
- fixtures/vcr_cassettes/express_checkout/configured.yml
|
176
|
+
- fixtures/vcr_cassettes/express_checkout/unknown.yml
|
177
|
+
- fixtures/vcr_cassettes/transitions/default/unknown/source_tree_id.yml
|
178
|
+
- fixtures/vcr_cassettes/transitions/many.yml
|
179
|
+
- fixtures/vcr_cassettes/transitions/one.yml
|
180
|
+
- fixtures/vcr_cassettes/transitions/unknown/source_tree_id.yml
|
181
|
+
- fixtures/vcr_cassettes/upgrade/default.yml
|
182
|
+
- fixtures/vcr_cassettes/upgrade/noop.yml
|
183
|
+
- fixtures/vcr_cassettes/upgrade/unknown/resource_id.yml
|
184
|
+
- fixtures/vcr_cassettes/upgrade/unknown/resource_type.yml
|
185
|
+
- fixtures/vcr_cassettes/upgrade/unknown/target_tree_id.yml
|
186
|
+
- lib/ruby-ecomm-client.rb
|
187
|
+
- lib/ruby-ecomm-client/client.rb
|
188
|
+
- lib/ruby-ecomm-client/converter.rb
|
189
|
+
- lib/ruby-ecomm-client/error.rb
|
190
|
+
- lib/ruby-ecomm-client/version.rb
|
191
|
+
- lib/ruby-ecomm-client/wsdl/manager.wsdl
|
192
|
+
- lib/ruby-ecomm-client/wsdl/profile.wsdl
|
193
|
+
- lib/ruby-ecomm-client/wsdl/purchase.wsdl
|
194
|
+
- ruby-ecomm-client.gemspec
|
195
|
+
- script/cibuild
|
196
|
+
- spec/ruby-ecomm-client/client_spec.rb
|
197
|
+
- spec/ruby-ecomm-client/converter_spec.rb
|
198
|
+
- spec/ruby-ecomm-client/error_spec.rb
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
homepage: https://github.secureserver.net/outright/ruby-ecomm-client
|
201
|
+
licenses: []
|
202
|
+
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
hash: 3
|
214
|
+
segments:
|
215
|
+
- 0
|
216
|
+
version: "0"
|
217
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
hash: 3
|
223
|
+
segments:
|
224
|
+
- 0
|
225
|
+
version: "0"
|
226
|
+
requirements: []
|
227
|
+
|
228
|
+
rubyforge_project:
|
229
|
+
rubygems_version: 1.8.15
|
230
|
+
signing_key:
|
231
|
+
specification_version: 3
|
232
|
+
summary: Easy access to the e-commerce web services via Ruby
|
233
|
+
test_files:
|
234
|
+
- spec/ruby-ecomm-client/client_spec.rb
|
235
|
+
- spec/ruby-ecomm-client/converter_spec.rb
|
236
|
+
- spec/ruby-ecomm-client/error_spec.rb
|
237
|
+
- spec/spec_helper.rb
|