rebay 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ group :dependencies do
4
+ gem 'json'
5
+ end
6
+
7
+ group :development do
8
+ gem 'rspec'
9
+ gem 'bundler', '>= 1.0.0'
10
+ gem 'jeweler', '>= 1.5.2'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ json (1.5.1)
11
+ rake (0.8.7)
12
+ rspec (2.5.0)
13
+ rspec-core (~> 2.5.0)
14
+ rspec-expectations (~> 2.5.0)
15
+ rspec-mocks (~> 2.5.0)
16
+ rspec-core (2.5.1)
17
+ rspec-expectations (2.5.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.5.0)
20
+ watchr (0.7)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (>= 1.0.0)
27
+ jeweler (>= 1.5.2)
28
+ json
29
+ rspec
30
+ watchr
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.1.3
data/lib/rebay.rb CHANGED
@@ -2,7 +2,3 @@ require 'rebay/api'
2
2
  require 'rebay/finding'
3
3
  require 'rebay/shopping'
4
4
  require 'rebay/response'
5
-
6
- module Rebay
7
- require 'rebay/railtie' if defined?(Rails) && Rails::VERSION::MAJOR == 3
8
- end
@@ -8,11 +8,11 @@ module Rebay
8
8
  end
9
9
 
10
10
  def success?
11
- return @response["Ack"] == 'Success'
11
+ @response["Ack"] == 'Success' || @response['ack'] == 'Success'
12
12
  end
13
13
 
14
14
  def failure?
15
- return @response["Ack"] == 'Failure'
15
+ @response["Ack"] == 'Failure' || @response['ack'] == 'Failure'
16
16
  end
17
17
 
18
18
  def trim(key)
@@ -64,4 +64,4 @@ module Rebay
64
64
  end
65
65
  end
66
66
  end
67
- end
67
+ end
data/rebay.gemspec CHANGED
@@ -1,58 +1,59 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{rebay}
8
- s.version = "1.1.2"
7
+ s.name = "rebay"
8
+ s.version = "1.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chuck Collins"]
12
- s.date = %q{2010-11-06}
13
- s.email = %q{chuck.collins@gmail.com}
12
+ s.date = "2012-02-17"
13
+ s.email = "chuck.collins@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
16
- "README.md"
16
+ "README.md"
17
17
  ]
18
18
  s.files = [
19
+ "Gemfile",
20
+ "Gemfile.lock",
19
21
  "LICENSE",
20
- "README.md",
21
- "Rakefile",
22
- "VERSION",
23
- "config.rb",
24
- "init.rb",
25
- "lib/rebay.rb",
26
- "lib/rebay/api.rb",
27
- "lib/rebay/finding.rb",
28
- "lib/rebay/railtie.rb",
29
- "lib/rebay/response.rb",
30
- "lib/rebay/shopping.rb",
31
- "rebay.gemspec"
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "init.rb",
26
+ "lib/rebay.rb",
27
+ "lib/rebay/api.rb",
28
+ "lib/rebay/finding.rb",
29
+ "lib/rebay/railtie.rb",
30
+ "lib/rebay/response.rb",
31
+ "lib/rebay/shopping.rb",
32
+ "rebay.gemspec"
32
33
  ]
33
- s.homepage = %q{http://github.com/ccollins/rebay}
34
- s.rdoc_options = ["--charset=UTF-8"]
34
+ s.homepage = "http://github.com/ccollins/rebay"
35
35
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
37
- s.summary = %q{Client for the RESTful JSON ebay finding and shopping api}
38
- s.test_files = [
39
- "spec/api_spec.rb",
40
- "spec/finding_spec.rb",
41
- "spec/response_spec.rb",
42
- "spec/shopping_spec.rb",
43
- "spec/spec_helper.rb"
44
- ]
36
+ s.rubygems_version = "1.8.11"
37
+ s.summary = "Client for the RESTful JSON ebay finding and shopping api"
45
38
 
46
39
  if s.respond_to? :specification_version then
47
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
40
  s.specification_version = 3
49
41
 
50
42
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ s.add_development_dependency(%q<rspec>, [">= 0"])
44
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
45
+ s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
51
46
  s.add_runtime_dependency(%q<json>, [">= 0"])
52
47
  else
48
+ s.add_dependency(%q<rspec>, [">= 0"])
49
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
50
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
53
51
  s.add_dependency(%q<json>, [">= 0"])
54
52
  end
55
53
  else
54
+ s.add_dependency(%q<rspec>, [">= 0"])
55
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
56
+ s.add_dependency(%q<jeweler>, [">= 1.5.2"])
56
57
  s.add_dependency(%q<json>, [">= 0"])
57
58
  end
58
59
  end
metadata CHANGED
@@ -1,50 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rebay
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 1
8
- - 2
9
- version: 1.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.3
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Chuck Collins
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-11-06 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: json
12
+ date: 2012-02-17 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &70147704523280 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70147704523280
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70147704517520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
22
34
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
35
+ version_requirements: *70147704517520
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &70147704513820 !ruby/object:Gem::Requirement
24
39
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.2
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70147704513820
47
+ - !ruby/object:Gem::Dependency
48
+ name: json
49
+ requirement: &70147704510340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
31
55
  type: :runtime
32
- version_requirements: *id001
56
+ prerelease: false
57
+ version_requirements: *70147704510340
33
58
  description:
34
59
  email: chuck.collins@gmail.com
35
60
  executables: []
36
-
37
61
  extensions: []
38
-
39
- extra_rdoc_files:
62
+ extra_rdoc_files:
40
63
  - LICENSE
41
64
  - README.md
42
- files:
65
+ files:
66
+ - Gemfile
67
+ - Gemfile.lock
43
68
  - LICENSE
44
69
  - README.md
45
70
  - Rakefile
46
71
  - VERSION
47
- - config.rb
48
72
  - init.rb
49
73
  - lib/rebay.rb
50
74
  - lib/rebay/api.rb
@@ -53,46 +77,28 @@ files:
53
77
  - lib/rebay/response.rb
54
78
  - lib/rebay/shopping.rb
55
79
  - rebay.gemspec
56
- - spec/api_spec.rb
57
- - spec/finding_spec.rb
58
- - spec/response_spec.rb
59
- - spec/shopping_spec.rb
60
- - spec/spec_helper.rb
61
- has_rdoc: true
62
80
  homepage: http://github.com/ccollins/rebay
63
81
  licenses: []
64
-
65
82
  post_install_message:
66
- rdoc_options:
67
- - --charset=UTF-8
68
- require_paths:
83
+ rdoc_options: []
84
+ require_paths:
69
85
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
86
+ required_ruby_version: !ruby/object:Gem::Requirement
71
87
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- version: "0"
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
86
98
  requirements: []
87
-
88
99
  rubyforge_project:
89
- rubygems_version: 1.3.7
100
+ rubygems_version: 1.8.11
90
101
  signing_key:
91
102
  specification_version: 3
92
103
  summary: Client for the RESTful JSON ebay finding and shopping api
93
- test_files:
94
- - spec/api_spec.rb
95
- - spec/finding_spec.rb
96
- - spec/response_spec.rb
97
- - spec/shopping_spec.rb
98
- - spec/spec_helper.rb
104
+ test_files: []
data/config.rb DELETED
@@ -1,3 +0,0 @@
1
- Rebay::Api.configure do |rebay|
2
- rebay.app_id = 'searched-8e3a-4e50-af08-c2e48cb3b020'
3
- end
data/spec/api_spec.rb DELETED
@@ -1,48 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- module Rebay
4
- describe Api do
5
- it "should respond to configure" do
6
- Rebay::Api.should respond_to(:configure)
7
- end
8
-
9
- it "should allow setting of app_id" do
10
- Rebay::Api.should respond_to(:app_id=)
11
- end
12
-
13
- it "should allow getting of app_id" do
14
- Rebay::Api.should respond_to(:app_id)
15
- end
16
-
17
- it "should return app id after configureation" do
18
- app_id = Rebay::Api.app_id
19
- Rebay::Api.configure do |rebay|
20
- rebay.app_id = 'test'
21
- end
22
- Rebay::Api.app_id.should == 'test'
23
- Rebay::Api.configure do |rebay|
24
- rebay.app_id = app_id
25
- end
26
- end
27
-
28
- context "when calling build_rest_payload" do
29
- before(:each) do
30
- @api = Rebay::Api.new
31
- end
32
-
33
- it "should build rest payload from hash" do
34
- payload = @api.send(:build_rest_payload, {:test=>'blah', :test2=>'blah', :test3=>'blah'})
35
- payload.should include("&test=blah")
36
- payload.should include("&test2=blah")
37
- payload.should include("&test3=blah")
38
- end
39
-
40
- it "should escape html chars" do
41
- payload = @api.send(:build_rest_payload, {:test=>'blah', :test2=>'blah', :test3=>'blah blah'})
42
- payload.should include("&test=blah")
43
- payload.should include("&test2=blah")
44
- payload.should include("&test3=blah%20blah")
45
- end
46
- end
47
- end
48
- end
data/spec/finding_spec.rb DELETED
@@ -1,238 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- module Rebay
4
- describe Finding do
5
- before(:each) do
6
- @finder = Finding.new
7
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new({"Ack" => 'Success'}))
8
- end
9
-
10
- it "should specify base url" do
11
- Finding::BASE_URL.should_not be_nil
12
- end
13
-
14
- it "should specify version" do
15
- Finding::VERSION.should_not be_nil
16
- end
17
-
18
- context "after creation" do
19
- it "should provide find_items_advanced" do
20
- @finder.should respond_to(:find_items_advanced)
21
- end
22
-
23
- it "should provide find_items_by_category" do
24
- @finder.should respond_to(:find_items_by_category)
25
- end
26
-
27
- it "should provide find_items_by_product" do
28
- @finder.should respond_to(:find_items_by_product)
29
- end
30
-
31
- it "should provide find_items_in_ebay_stores" do
32
- @finder.should respond_to(:find_items_in_ebay_stores)
33
- end
34
-
35
- it "should provide get_histograms" do
36
- @finder.should respond_to(:get_histograms)
37
- end
38
-
39
- it "should provide get_search_keywords_recommendation" do
40
- @finder.should respond_to(:get_search_keywords_recommendation)
41
- end
42
-
43
- it "should provide get_version" do
44
- @finder.should respond_to(:get_version)
45
- end
46
- end
47
-
48
- context "when calling find_items_advanced" do
49
- it "should fail without args" do
50
- lambda { @finder.find_items_advanced }.should raise_error(ArgumentError)
51
- end
52
-
53
- it "should return a hash response with categoryId as parameter" do
54
- @finder.find_items_advanced({:categoryId => 1}).class.should eq(Rebay::Response)
55
- end
56
-
57
- it "should return a hash response with keywords as parameter" do
58
- @finder.find_items_advanced({:keywords => 'feist'}).class.should eq(Rebay::Response)
59
- end
60
-
61
- it "should succeed" do
62
- @finder.find_items_advanced({:keywords => 'feist'}).success?.should be_true
63
- end
64
-
65
- it "should iterate over results" do
66
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced"))
67
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
68
- response = @finder.find_items_advanced({:keywords => 'whatevs'})
69
-
70
- count = 0
71
- response.each { |r| count = count + 1 }
72
- count.should eq(2)
73
- end
74
-
75
- it "should work with 1 result" do
76
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced_one_item"))
77
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
78
- response = @finder.find_items_advanced({:categoryId => 1})
79
- count = 0
80
-
81
- response.each { |r| count = count + 1 }
82
- count.should eq(1)
83
- end
84
- end
85
-
86
- context "when calling find_items_by_category" do
87
- it "should fail without args" do
88
- lambda { @finder.get_search_keywords_recommendation }.should raise_error(ArgumentError)
89
- end
90
-
91
- it "should return a hash response" do
92
- @finder.find_items_by_category({:categoryId => 1}).class.should eq(Rebay::Response)
93
- end
94
-
95
- it "should succeed" do
96
- @finder.find_items_by_category({:categoryId => 1}).success?.should be_true
97
- end
98
-
99
- it "should iterate over results" do
100
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_category"))
101
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
102
- response = @finder.find_items_by_category({:categoryId => 1})
103
-
104
- count = 0
105
- response.each { |r| count = count + 1 }
106
- count.should eq(2)
107
- end
108
- end
109
-
110
- context "when calling find_items_by_product" do
111
- it "should fail without args" do
112
- lambda { @finder.find_items_by_product }.should raise_error(ArgumentError)
113
- end
114
-
115
- it "should return a hash response" do
116
- @finder.find_items_by_product({:productId => 53039031}).class.should eq(Rebay::Response)
117
- end
118
-
119
- it "should succeed" do
120
- @finder.find_items_by_product({:productId => 53039031}).success?.should be_true
121
- end
122
-
123
- it "should iterate over results" do
124
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_product"))
125
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
126
- response = @finder.find_items_by_product({:productId => 1})
127
-
128
- count = 0
129
- response.each { |r| count = count + 1 }
130
- count.should eq(2)
131
- end
132
- end
133
-
134
- context "when calling find_items_by_keywords" do
135
- it "should fail without args" do
136
- lambda { @finder.find_items_by_keywords }.should raise_error(ArgumentError)
137
- end
138
-
139
- it "should return a hash response" do
140
- @finder.find_items_by_keywords({:keywords => 'feist'}).class.should eq(Rebay::Response)
141
- end
142
-
143
- it "should succeed" do
144
- @finder.find_items_by_keywords({:keywords => 'feist'}).success?.should be_true
145
- end
146
-
147
- it "should iterate over results" do
148
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_keywords"))
149
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
150
- response = @finder.find_items_by_keywords({:keywords => 'whatevs'})
151
-
152
- count = 0
153
- response.each { |r| count = count + 1 }
154
- count.should eq(2)
155
- end
156
- end
157
-
158
- context "when calling find_items_in_ebay_stores" do
159
- it "should fail without args" do
160
- lambda { @finder.find_items_in_ebay_stores }.should raise_error(ArgumentError)
161
- end
162
-
163
- it "should return a hash response with storeName as parameter" do
164
- @finder.find_items_in_ebay_stores({:storeName => 'Laura_Chen\'s_Small_Store'}).class.should eq(Rebay::Response)
165
- end
166
-
167
- it "should return a hash response with keywords as parameter" do
168
- @finder.find_items_in_ebay_stores({:keywords => 'feist'}).class.should eq(Rebay::Response)
169
- end
170
-
171
- it "should succeed" do
172
- @finder.find_items_in_ebay_stores({:keywords => 'feist'}).success?.should be_true
173
- end
174
- end
175
-
176
- context "when calling get_histograms" do
177
- it "should fail without args" do
178
- lambda { @finder.get_histograms }.should raise_error(ArgumentError)
179
- end
180
-
181
- it "should return a hash response" do
182
- @finder.get_histograms({:categoryId => 1}).class.should eq(Rebay::Response)
183
- end
184
-
185
- it "should succeed" do
186
- @finder.get_histograms({:categoryId => 1}).success?.should be_true
187
- end
188
- end
189
-
190
- context "when calling get_search_keywords_recommendation" do
191
- it "should fail without args" do
192
- lambda { @finder.get_search_keywords_recommendation }.should raise_error(ArgumentError)
193
- end
194
-
195
- it "should return a hash response" do
196
- @finder.get_search_keywords_recommendation({:keywords => 'feist'}).class.should eq(Rebay::Response)
197
- end
198
-
199
- it "should succeed" do
200
- @finder.get_search_keywords_recommendation({:keywords => 'feist'}).success?.should be_true
201
- end
202
-
203
- it "should iterate over results" do
204
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation"))
205
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
206
- response = @finder.get_search_keywords_recommendation({:keywords => 'whatevs'})
207
-
208
- count = 0
209
- response.each { |r| count = count + 1 }
210
- count.should eq(1)
211
-
212
- response.results.should eq('harry potter phoenix')
213
- end
214
- end
215
-
216
- context "when calling get_version" do
217
- it "should return a hash response" do
218
- @finder.get_version.class.should eq(Rebay::Response)
219
- end
220
-
221
- it "should succeed" do
222
- @finder.get_version.success?.should be_true
223
- end
224
-
225
- it "should iterate over results" do
226
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_version"))
227
- @finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
228
- response = @finder.get_version
229
-
230
- count = 0
231
- response.each { |r| count = count + 1 }
232
- count.should eq(1)
233
-
234
- response.results.should eq('1.8.0')
235
- end
236
- end
237
- end
238
- end
@@ -1,120 +0,0 @@
1
- require File.dirname(__FILE__) + "/spec_helper"
2
-
3
- module Rebay
4
- describe Response do
5
- context "on creation" do
6
- it "should transform the happy json" do
7
- json_happy = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_happy"))
8
- response = Response.new(json_happy)
9
- response.response.should eq({"getSearchKeywordsRecommendationResponse" => {"ack" => "Success", "version" => "1.5.0",
10
- "timestamp" => "2010-08-13T21:11:02.539Z", "keywords" => "accordion"}})
11
- end
12
-
13
- it "should transform the sad json" do
14
- json_sad = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_sad"))
15
- response = Response.new(json_sad)
16
- response.response.should eq({"getSearchKeywordsRecommendationResponse" =>
17
- {"ack" => "Warning",
18
- "errorMessage" => {"error" => {"errorId" => "59", "domain" => "Marketplace", "severity" => "Warning",
19
- "category" => "Request", "message" => "No recommendation was identified for the submitted keywords.",
20
- "subdomain" => "Search"}},
21
- "version" => "1.5.0",
22
- "timestamp" => "2010-08-13T21:08:30.081Z",
23
- "keywords" => ""}})
24
- end
25
- end
26
-
27
- it "should return success" do
28
- response = Response.new({"Ack" => "Success"})
29
- response.success?.should be_true
30
- response.failure?.should be_false
31
- end
32
-
33
- it "should return failure" do
34
- response = Response.new({"Ack" => "Failure"})
35
- response.failure?.should be_true
36
- response.success?.should be_false
37
- end
38
-
39
- it "should trim response" do
40
- response = Response.new({"Ack" => "Failure", "test" => "test"})
41
- response.trim("test")
42
- response.response.should eq("test")
43
- end
44
-
45
- it "should trim response with syn" do
46
- response = Response.new({"Ack" => "Failure", "test" => "test"})
47
- response.trim(:test)
48
- response.response.should eq("test")
49
- end
50
-
51
- it "should not trim response" do
52
- response = Response.new({"Ack" => "Failure", "test" => "test"})
53
- response.trim(:nothing)
54
- response.response.should eq({"Ack" => "Failure", "test" => "test"})
55
- end
56
-
57
- it "should set result key" do
58
- response = Response.new({})
59
- response.should respond_to(:results)
60
- end
61
-
62
- it "should provide empty iterator without a result key" do
63
- response = Response.new({})
64
- count = 0
65
- response.each { |r| count = count + 1 }
66
- count.should eq(0)
67
- end
68
-
69
- context "using find items advanced json" do
70
- before(:each) do
71
- @json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced"))
72
- @response = Response.new(@json)
73
- @response.trim(:findItemsAdvancedResponse)
74
- @proper = {"ack"=>"Success", "version"=>"1.7.0", "timestamp"=>"2010-09-29T01:53:58.039Z",
75
- "searchResult"=>{"@count"=>"2",
76
- "item"=>[{"itemId"=>"300471157219","title"=>"Minas Tirith 1990 Tolkien fanzine journal LOTR Hobbit",
77
- "globalId"=>"EBAY-US","primaryCategory"=>{"categoryId"=>"280","categoryName"=>"Magazine Back Issues"},
78
- "secondaryCategory"=>{"categoryId"=>"29799","categoryName"=>"Other"},
79
- "galleryURL"=>"http:\/\/thumbs4.ebaystatic.com\/pict\/3004711572198080_1.jpg",
80
- "viewItemURL"=>"http:\/\/cgi.ebay.com\/Minas-Tirith-1990-Tolkien-fanzine-journal-LOTR-Hobbit-\/300471157219?pt=Magazines",
81
- "paymentMethod"=>"PayPal","autoPay"=>"false","postalCode"=>"55403","location"=>"Minneapolis,MN,USA",
82
- "country"=>"US","shippingInfo"=>{"shippingServiceCost"=>{"@currencyId"=>"USD","__value__"=>"2.99"},
83
- "shippingType"=>"Flat","shipToLocations"=>"Worldwide"},
84
- "sellingStatus"=>{"currentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
85
- "convertedCurrentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
86
- "bidCount"=>"1","sellingState"=>"Active","timeLeft"=>"P0DT0H3M56S"},
87
- "listingInfo"=>{"bestOfferEnabled"=>"false","buyItNowAvailable"=>"false",
88
- "startTime"=>"2010-09-22T01:57:54.000Z","endTime"=>"2010-09-29T01:57:54.000Z",
89
- "listingType"=>"Auction","gift"=>"false"},
90
- "condition"=>{"conditionId"=>"4000","conditionDisplayName"=>"Very Good"}},
91
- {"itemId"=>"300471157219","title"=>"Minas Tirith 1990 Tolkien fanzine journal LOTR Hobbit",
92
- "globalId"=>"EBAY-US","primaryCategory"=>{"categoryId"=>"280","categoryName"=>"Magazine Back Issues"},
93
- "secondaryCategory"=>{"categoryId"=>"29799","categoryName"=>"Other"},
94
- "galleryURL"=>"http:\/\/thumbs4.ebaystatic.com\/pict\/3004711572198080_1.jpg",
95
- "viewItemURL"=>"http:\/\/cgi.ebay.com\/Minas-Tirith-1990-Tolkien-fanzine-journal-LOTR-Hobbit-\/300471157219?pt=Magazines",
96
- "paymentMethod"=>"PayPal","autoPay"=>"false","postalCode"=>"55403","location"=>"Minneapolis,MN,USA",
97
- "country"=>"US","shippingInfo"=>{"shippingServiceCost"=>{"@currencyId"=>"USD","__value__"=>"2.99"},
98
- "shippingType"=>"Flat","shipToLocations"=>"Worldwide"},
99
- "sellingStatus"=>{"currentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
100
- "convertedCurrentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
101
- "bidCount"=>"1","sellingState"=>"Active","timeLeft"=>"P0DT0H3M56S"},
102
- "listingInfo"=>{"bestOfferEnabled"=>"false","buyItNowAvailable"=>"false",
103
- "startTime"=>"2010-09-22T01:57:54.000Z","endTime"=>"2010-09-29T01:57:54.000Z",
104
- "listingType"=>"Auction","gift"=>"false"},
105
- "condition"=>{"conditionId"=>"4000","conditionDisplayName"=>"Very Good"}}]},
106
- "paginationOutput"=>{"pageNumber"=>"1","entriesPerPage"=>"2","totalPages"=>"2359","totalEntries"=>"4717"},
107
- "itemSearchURL"=>"http:\/\/shop.ebay.com\/i.html?_nkw=tolkien&_ddo=1&_ipg=2&_pgn=1"}
108
- @response.results = @response.response['searchResult']['item']
109
- end
110
-
111
- it "should trim format response correctly" do
112
- @response.response.should eq(@proper)
113
- end
114
-
115
- it "should show correct size" do
116
- @response.size.should eq(2)
117
- end
118
- end
119
- end
120
- end
@@ -1,274 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- module Rebay
4
- describe Shopping do
5
- before(:each) do
6
- @shopper = Shopping.new
7
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new({"Ack" => "Success"}))
8
- end
9
-
10
- it "should specify base url" do
11
- Shopping::BASE_URL.should_not be_nil
12
- end
13
-
14
- it "should specify version" do
15
- Shopping::VERSION.should_not be_nil
16
- end
17
-
18
- context "after creation" do
19
- it "should provide get_category_info" do
20
- @shopper.should respond_to(:get_category_info)
21
- end
22
-
23
- it "should provide get_category_info_with_children" do
24
- @shopper.should respond_to(:get_category_info_with_children)
25
- end
26
-
27
- it "should provide find_products" do
28
- @shopper.should respond_to(:find_products)
29
- end
30
-
31
- it "should provide find_half_products" do
32
- @shopper.should respond_to(:find_half_products)
33
- end
34
-
35
- it "should provide get_single_item" do
36
- @shopper.should respond_to(:get_single_item)
37
- end
38
-
39
- it "should provide get_item_status" do
40
- @shopper.should respond_to(:get_item_status)
41
- end
42
-
43
- it "should provide get_shipping_costs" do
44
- @shopper.should respond_to(:get_shipping_costs)
45
- end
46
-
47
- it "should provide get_multiple_items" do
48
- @shopper.should respond_to(:get_multiple_items)
49
- end
50
-
51
- it "should provide get_user_profile" do
52
- @shopper.should respond_to(:get_user_profile)
53
- end
54
-
55
- it "should provide find_popular_searches" do
56
- @shopper.should respond_to(:find_popular_searches)
57
- end
58
-
59
- it "should provide find_popular_items" do
60
- @shopper.should respond_to(:find_popular_items)
61
- end
62
-
63
- it "should provide find_reviews_and_guides" do
64
- @shopper.should respond_to(:find_reviews_and_guides)
65
- end
66
- end
67
-
68
- context "when calling get_category_info" do
69
- it "should fail without args" do
70
- lambda { @shopper.get_category_info }.should raise_error(ArgumentError)
71
- end
72
-
73
- it "should return a hash response" do
74
- @shopper.get_category_info({:categoryId => 29223}).class.should eq(Rebay::Response)
75
- end
76
-
77
- it "should succeed" do
78
- @shopper.get_category_info({:categoryId => 29223}).success?.should be_true
79
- end
80
-
81
- it "should iterate over results" do
82
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/get_category_info"))
83
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
84
- response = @shopper.get_category_info({:categoryId => 1})
85
-
86
- count = 0
87
- response.each { |r| count = count + 1 }
88
- count.should eq(1)
89
- end
90
- end
91
-
92
- context "when calling find_products" do
93
- it "should fail without args" do
94
- lambda { @shopper.find_products }.should raise_error(ArgumentError)
95
- end
96
-
97
- it "should return a hash response" do
98
- @shopper.find_products({:queryKeywords => 'harry potter'}).class.should eq(Rebay::Response)
99
- end
100
-
101
- it "should succeed" do
102
- @shopper.find_products({:queryKeywords => 'harry potter'}).success?.should be_true
103
- end
104
-
105
- it "should iterate over results" do
106
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_products"))
107
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
108
- response = @shopper.find_products({:queryKeywords => 'whatevs'})
109
-
110
- count = 0
111
- response.each { |r| count = count + 1 }
112
- count.should eq(2)
113
- end
114
- end
115
-
116
- context "when calling find_half_products" do
117
- it "should fail without args" do
118
- lambda { @shopper.find_half_products }.should raise_error(ArgumentError)
119
- end
120
-
121
- it "should return a hash response" do
122
- @shopper.find_half_products({:queryKeywords => 'harry potter'}).class.should eq(Rebay::Response)
123
- end
124
-
125
- it "should succeed" do
126
- @shopper.find_half_products({:queryKeywords => 'harry potter'}).success?.should be_true
127
- end
128
-
129
- it "should iterate over results" do
130
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_half_products"))
131
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
132
- response = @shopper.find_half_products({:queryKeywords => 'whatevs'})
133
-
134
- count = 0
135
- response.each { |r| count = count + 1 }
136
- count.should eq(2)
137
- end
138
- end
139
-
140
- context "when calling get_single_item" do
141
- it "should fail without args" do
142
- lambda { @shopper.get_single_item }.should raise_error(ArgumentError)
143
- end
144
-
145
- it "should return a hash response" do
146
- @shopper.get_single_item({:itemId => 230139965209}).class.should eq(Rebay::Response)
147
- end
148
-
149
- it "should succeed" do
150
- @shopper.get_single_item({:itemId => 230139965209}).success?.should be_true
151
- end
152
- end
153
-
154
- context "when calling get_item_status" do
155
- it "should fail without args" do
156
- lambda { @shopper.get_item_status }.should raise_error(ArgumentError)
157
- end
158
-
159
- it "should return a hash response" do
160
- @shopper.get_item_status({:itemId => 230139965209}).class.should eq(Rebay::Response)
161
- end
162
-
163
- it "should succeed" do
164
- @shopper.get_item_status({:itemId => 230139965209}).success?.should be_true
165
- end
166
- end
167
-
168
- context "when calling get_shipping_costs" do
169
- it "should fail without args" do
170
- lambda { @shopper.get_shipping_costs }.should raise_error(ArgumentError)
171
- end
172
-
173
- it "should return a hash response" do
174
- @shopper.get_shipping_costs({:itemId => 230139965209}).class.should eq(Rebay::Response)
175
- end
176
-
177
- it "should succeed" do
178
- @shopper.get_shipping_costs({:itemId => 230139965209}).success?.should be_true
179
- end
180
- end
181
-
182
- context "when calling get_multiple_items" do
183
- it "should fail without args" do
184
- lambda { @shopper.get_multiple_items }.should raise_error(ArgumentError)
185
- end
186
-
187
- it "should return a hash response" do
188
- @shopper.get_multiple_items({:itemId => 230139965209}).class.should eq(Rebay::Response)
189
- end
190
-
191
- it "should succeed" do
192
- @shopper.get_multiple_items({:itemId => 230139965209}).success?.should be_true
193
- end
194
- end
195
-
196
- context "when calling get_user_profile" do
197
- it "should fail without args" do
198
- lambda { @shopper.get_user_profile }.should raise_error(ArgumentError)
199
- end
200
-
201
- it "should return a hash response" do
202
- @shopper.get_user_profile({:userId => 1}).class.should eq(Rebay::Response)
203
- end
204
-
205
- it "should succeed" do
206
- @shopper.get_user_profile({:userId => 1}).success?.should be_true
207
- end
208
- end
209
-
210
- context "when calling find_popular_searches" do
211
- it "should fail without args" do
212
- lambda { @shopper.find_popular_searches }.should raise_error(ArgumentError)
213
- end
214
-
215
- it "should return a hash response" do
216
- @shopper.find_popular_searches({:categoryId => 1}).class.should eq(Rebay::Response)
217
- end
218
-
219
- it "should succeed" do
220
- @shopper.find_popular_searches({:categoryId => 1}).success?.should be_true
221
- end
222
-
223
- it "should iterate over results" do
224
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_searches"))
225
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
226
- response = @shopper.find_popular_searches({:categoryId => 1})
227
-
228
- count = 0
229
- response.each { |r| count = count + 1 }
230
- count.should eq(1)
231
- end
232
- end
233
-
234
- context "when calling find_popular_items" do
235
- it "should return a hash response" do
236
- @shopper.find_popular_items({:categoryId => 1}).class.should eq(Rebay::Response)
237
- end
238
-
239
- it "should succeed" do
240
- @shopper.find_popular_items({:categoryId => 1}).success?.should be_true
241
- end
242
-
243
- it "should iterate over results" do
244
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_items"))
245
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
246
- response = @shopper.find_popular_items({:categoryId => 1})
247
-
248
- count = 0
249
- response.each { |r| count = count + 1 }
250
- count.should eq(19)
251
- end
252
- end
253
-
254
- context "when calling find_reviews_and_guides" do
255
- it "should return a hash response" do
256
- @shopper.find_reviews_and_guides.class.should eq(Rebay::Response)
257
- end
258
-
259
- it "should succeed" do
260
- @shopper.find_reviews_and_guides.success?.should be_true
261
- end
262
-
263
- it "should iterate over results" do
264
- json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_reviews_and_guides"))
265
- @shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
266
- response = @shopper.find_reviews_and_guides
267
-
268
- count = 0
269
- response.each { |r| count = count + 1 }
270
- count.should eq(5)
271
- end
272
- end
273
- end
274
- end
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rspec'
2
- RSpec.configure do |config|
3
- config.mock_with :rspec
4
- end
5
-
6
- require File.join(File.dirname(__FILE__), "..", "lib", "rebay")
7
-
8
- Rebay::Api.configure do |rebay|
9
- rebay.app_id = 'test'
10
- end