rakuten_web_service 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/rakuten_web_service/books/genre.rb +1 -1
- data/lib/rakuten_web_service/books/resource.rb +4 -0
- data/lib/rakuten_web_service/genre.rb +11 -3
- data/lib/rakuten_web_service/genre_information.rb +13 -0
- data/lib/rakuten_web_service/ichiba/genre.rb +1 -1
- data/lib/rakuten_web_service/ichiba/item.rb +4 -0
- data/lib/rakuten_web_service/kobo/ebook.rb +4 -0
- data/lib/rakuten_web_service/kobo/genre.rb +1 -1
- data/lib/rakuten_web_service/resource.rb +13 -0
- data/lib/rakuten_web_service/response.rb +6 -0
- data/lib/rakuten_web_service/search_result.rb +5 -0
- data/lib/rakuten_web_service/version.rb +1 -1
- data/spec/fixtures/books/book_search_with_keyword_Ruby.json +1245 -1
- data/spec/fixtures/ichiba/item_search_with_keyword_Ruby.json +1956 -1
- data/spec/fixtures/ichiba/parents_genre_search.json +1 -0
- data/spec/fixtures/kobo/ebook_search_with_Ruby.json +927 -1
- data/spec/rakuten_web_service/books/book_spec.rb +24 -0
- data/spec/rakuten_web_service/genre_information_spec.rb +125 -0
- data/spec/rakuten_web_service/ichiba/genre_spec.rb +19 -0
- data/spec/rakuten_web_service/ichiba/item_spec.rb +24 -2
- data/spec/rakuten_web_service/kobo/ebook_spec.rb +23 -0
- metadata +7 -2
@@ -42,6 +42,30 @@ describe RakutenWebService::Books::Book do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
describe "#genre_information" do
|
46
|
+
before do
|
47
|
+
response = JSON.parse(fixture('books/book_search_with_keyword_Ruby.json'))
|
48
|
+
@expected_request = stub_request(:get, endpoint).
|
49
|
+
with(:query => expected_query).to_return(:body => response.to_json)
|
50
|
+
end
|
51
|
+
|
52
|
+
subject { RakutenWebService::Books::Book.search(title: 'Ruby') }
|
53
|
+
|
54
|
+
it "responds GenreInformation object" do
|
55
|
+
expect(subject.genre_information).to be_a(RakutenWebService::GenreInformation)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
describe "its attributes" do
|
60
|
+
subject { super().genre_information }
|
61
|
+
|
62
|
+
it "have current genre" do
|
63
|
+
expect(subject.current).to be_a(RakutenWebService::Books::Genre)
|
64
|
+
expect(subject.current.item_count).to eq('115')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
45
69
|
describe '#genre' do
|
46
70
|
let(:response) { JSON.parse(fixture('books/book_search_with_keyword_Ruby.json')) }
|
47
71
|
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RakutenWebService::GenreInformation do
|
4
|
+
describe '#initialize' do
|
5
|
+
subject { RakutenWebService::GenreInformation.new(expected_params, RWS::Ichiba::Genre) }
|
6
|
+
|
7
|
+
context "When given params only has children genres" do
|
8
|
+
let(:expected_params) do
|
9
|
+
{
|
10
|
+
"parent" => [],
|
11
|
+
"current" => [],
|
12
|
+
"children" => [
|
13
|
+
{
|
14
|
+
"child" => {
|
15
|
+
"genreId" => "564500",
|
16
|
+
"genreName" => "光回線・モバイル通信",
|
17
|
+
"itemCount" => "5",
|
18
|
+
"genreLevel" => "1"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
it { is_expected.to be_a(RakutenWebService::GenreInformation) }
|
26
|
+
specify "its parent should be nil" do
|
27
|
+
expect(subject.parent).to be_nil
|
28
|
+
end
|
29
|
+
specify "its current should be nil" do
|
30
|
+
expect(subject.current).to be_nil
|
31
|
+
end
|
32
|
+
specify "its children should returns a array of Genre" do
|
33
|
+
expect(subject.children).to_not be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "each child" do
|
37
|
+
subject { super().children.first }
|
38
|
+
|
39
|
+
it "has genre id" do
|
40
|
+
expect(subject.id).to eq('564500')
|
41
|
+
end
|
42
|
+
it "has genre name" do
|
43
|
+
expect(subject.name).to eq('光回線・モバイル通信')
|
44
|
+
end
|
45
|
+
it "has its genre level" do
|
46
|
+
expect(subject.level).to eq('1')
|
47
|
+
end
|
48
|
+
it "has its item count" do
|
49
|
+
expect(subject.item_count).to eq('5')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
context "When given params has current genre" do
|
54
|
+
let(:expected_params) do
|
55
|
+
{
|
56
|
+
"parent" => [],
|
57
|
+
"current" => [
|
58
|
+
{
|
59
|
+
"genreId" => "564500",
|
60
|
+
"genreName" => "スマートフォン・タブレット",
|
61
|
+
"itemCount" => "313045",
|
62
|
+
"genreLevel" => "1"
|
63
|
+
}
|
64
|
+
],
|
65
|
+
"children" => [
|
66
|
+
]
|
67
|
+
}
|
68
|
+
end
|
69
|
+
specify "its parent should be nil" do expect(subject.parent).to be_nil
|
70
|
+
end
|
71
|
+
specify "its current should be a Genre object" do
|
72
|
+
expect(subject.current).to be_a(RWS::Ichiba::Genre)
|
73
|
+
end
|
74
|
+
specify "its children should be empty" do
|
75
|
+
expect(subject.children).to be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
context "When given params has parent genre" do
|
79
|
+
let(:expected_params) do
|
80
|
+
{
|
81
|
+
"parent" => [
|
82
|
+
{
|
83
|
+
"genreId" => "564500",
|
84
|
+
"genreName" => "スマートフォン・タブレット",
|
85
|
+
"itemCount" => "313045",
|
86
|
+
"genreLevel" => "1"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"current" => [
|
90
|
+
{
|
91
|
+
"genreId" => "560029",
|
92
|
+
"genreName" => "タブレットPC本体",
|
93
|
+
"itemCount" => "0",
|
94
|
+
"genreLevel" => "2"
|
95
|
+
}
|
96
|
+
],
|
97
|
+
"children" => [
|
98
|
+
]
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
specify "its parent should be a Genre object" do
|
103
|
+
expect(subject.parent).to be_a(RWS::Ichiba::Genre)
|
104
|
+
end
|
105
|
+
specify "its current should be a Gere object" do
|
106
|
+
expect(subject.current).to be_a(RWS::Ichiba::Genre)
|
107
|
+
end
|
108
|
+
specify "its children should be empty" do
|
109
|
+
expect(subject.children).to be_empty
|
110
|
+
end
|
111
|
+
|
112
|
+
context "After re-initialize Genre with same genre id" do
|
113
|
+
let(:genre) { RWS::Ichiba::Genre.new('560029') }
|
114
|
+
|
115
|
+
before do
|
116
|
+
subject.current
|
117
|
+
end
|
118
|
+
|
119
|
+
it "doesn't have item_count value" do
|
120
|
+
expect(genre.item_count).to be_nil
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -141,6 +141,25 @@ describe RakutenWebService::Ichiba::Genre do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
describe '#parents' do
|
145
|
+
let(:genre_id) { 559887 }
|
146
|
+
let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
|
147
|
+
|
148
|
+
before do
|
149
|
+
stub_request(:get, endpoint).with(
|
150
|
+
query: {
|
151
|
+
affiliateId: affiliate_id,
|
152
|
+
applicationId: application_id,
|
153
|
+
genreId: genre_id
|
154
|
+
}
|
155
|
+
).to_return(body: fixture('ichiba/parents_genre_search.json'))
|
156
|
+
end
|
157
|
+
|
158
|
+
specify "should respond an array of parents Genres" do
|
159
|
+
expect(genre.parents).to be_a(Array)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
144
163
|
describe '#ranking' do
|
145
164
|
let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
|
146
165
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
3
|
describe RakutenWebService::Ichiba::Item do
|
@@ -30,6 +28,7 @@ describe RakutenWebService::Ichiba::Item do
|
|
30
28
|
response['page'] = 2
|
31
29
|
response['first'] = 31
|
32
30
|
response['last'] = 60
|
31
|
+
response['pageCount'] = 2
|
33
32
|
@second_request = stub_request(:get, endpoint).
|
34
33
|
with(:query => expected_query.merge(:page => 2)).
|
35
34
|
to_return(:body => response.to_json)
|
@@ -139,6 +138,7 @@ describe RakutenWebService::Ichiba::Item do
|
|
139
138
|
response['page'] = 2
|
140
139
|
response['first'] = 31
|
141
140
|
response['last'] = 60
|
141
|
+
response['pageCount'] = 2
|
142
142
|
@second_request = stub_request(:get, endpoint).
|
143
143
|
with(:query => expected_query.merge(:page => 2)).
|
144
144
|
to_return(:body => response.to_json)
|
@@ -163,6 +163,14 @@ describe RakutenWebService::Ichiba::Item do
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
+
describe ".genre_class" do
|
167
|
+
subject { RakutenWebService::Ichiba::Item }
|
168
|
+
|
169
|
+
it "returns RakutenWebService::Ichiba::Genre" do
|
170
|
+
expect(subject.genre_class).to eq(RakutenWebService::Ichiba::Genre)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
166
174
|
describe '#genre' do
|
167
175
|
let(:response) { JSON.parse(fixture('ichiba/item_search_with_keyword_Ruby.json')) }
|
168
176
|
|
@@ -217,4 +225,18 @@ describe RakutenWebService::Ichiba::Item do
|
|
217
225
|
expect(second_query.params[:sort]).to eq('-affiliateRate')
|
218
226
|
end
|
219
227
|
end
|
228
|
+
|
229
|
+
describe '#genre_information' do
|
230
|
+
before do
|
231
|
+
response = JSON.parse(fixture('ichiba/item_search_with_keyword_Ruby.json'))
|
232
|
+
@expected_request = stub_request(:get, endpoint).
|
233
|
+
with(query: expected_query).to_return(body: response.to_json)
|
234
|
+
end
|
235
|
+
|
236
|
+
subject { RWS::Ichiba::Item.search(keyword: 'Ruby').genre_information }
|
237
|
+
|
238
|
+
it "should be a GenreInformation" do
|
239
|
+
expect(subject).to be_a(RWS::GenreInformation)
|
240
|
+
end
|
241
|
+
end
|
220
242
|
end
|
@@ -36,6 +36,29 @@ describe RakutenWebService::Kobo::Ebook do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe "#genre_information" do
|
40
|
+
before do
|
41
|
+
response = JSON.parse(fixture('kobo/ebook_search_with_Ruby.json'))
|
42
|
+
stub_request(:get, endpoint).
|
43
|
+
with(:query => expected_query).to_return(:body => response.to_json)
|
44
|
+
end
|
45
|
+
|
46
|
+
subject { RakutenWebService::Kobo::Ebook.search(title: 'Ruby') }
|
47
|
+
|
48
|
+
it "returns GenreInformation object" do
|
49
|
+
expect(subject.genre_information).to be_a(RakutenWebService::GenreInformation)
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "its current attributes" do
|
53
|
+
subject { super().genre_information.current }
|
54
|
+
|
55
|
+
it "returns the current genre information" do
|
56
|
+
expect(subject.name).to eq("電子書籍")
|
57
|
+
expect(subject.item_count).to eq("660")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
39
62
|
describe '#genre' do
|
40
63
|
let(:response) { JSON.parse(fixture('kobo/ebook_search_with_Ruby.json')) }
|
41
64
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakuten_web_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/rakuten_web_service/configuration.rb
|
118
118
|
- lib/rakuten_web_service/error.rb
|
119
119
|
- lib/rakuten_web_service/genre.rb
|
120
|
+
- lib/rakuten_web_service/genre_information.rb
|
120
121
|
- lib/rakuten_web_service/gora.rb
|
121
122
|
- lib/rakuten_web_service/gora/course.rb
|
122
123
|
- lib/rakuten_web_service/gora/course_detail.rb
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- spec/fixtures/gora/plan_search_with_area_code.json
|
152
153
|
- spec/fixtures/ichiba/genre_search.json
|
153
154
|
- spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
|
155
|
+
- spec/fixtures/ichiba/parents_genre_search.json
|
154
156
|
- spec/fixtures/ichiba/product_search.json
|
155
157
|
- spec/fixtures/ichiba/ranking_search.json
|
156
158
|
- spec/fixtures/kobo/ebook_search_with_Ruby.json
|
@@ -168,6 +170,7 @@ files:
|
|
168
170
|
- spec/rakuten_web_service/books/total_spec.rb
|
169
171
|
- spec/rakuten_web_service/client_spec.rb
|
170
172
|
- spec/rakuten_web_service/configuration_spec.rb
|
173
|
+
- spec/rakuten_web_service/genre_information_spec.rb
|
171
174
|
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
172
175
|
- spec/rakuten_web_service/gora/course_spec.rb
|
173
176
|
- spec/rakuten_web_service/gora/plan_spec.rb
|
@@ -221,6 +224,7 @@ test_files:
|
|
221
224
|
- spec/fixtures/gora/plan_search_with_area_code.json
|
222
225
|
- spec/fixtures/ichiba/genre_search.json
|
223
226
|
- spec/fixtures/ichiba/item_search_with_keyword_Ruby.json
|
227
|
+
- spec/fixtures/ichiba/parents_genre_search.json
|
224
228
|
- spec/fixtures/ichiba/product_search.json
|
225
229
|
- spec/fixtures/ichiba/ranking_search.json
|
226
230
|
- spec/fixtures/kobo/ebook_search_with_Ruby.json
|
@@ -238,6 +242,7 @@ test_files:
|
|
238
242
|
- spec/rakuten_web_service/books/total_spec.rb
|
239
243
|
- spec/rakuten_web_service/client_spec.rb
|
240
244
|
- spec/rakuten_web_service/configuration_spec.rb
|
245
|
+
- spec/rakuten_web_service/genre_information_spec.rb
|
241
246
|
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
242
247
|
- spec/rakuten_web_service/gora/course_spec.rb
|
243
248
|
- spec/rakuten_web_service/gora/plan_spec.rb
|