rakuten_web_service 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aeee894eae4b8fd7ae21d2962ed0fe90eee73cf
|
4
|
+
data.tar.gz: bebc76e67f7bbc00a0f89d2f1e68efbdc5fc6767
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3df84fcdd99a3fa8ee8a1b9703bb96516e3055ca9ba653ef6c822834218b53e7e150526af7e1c3f750ce391e0f26575b648c4b8388ca2631ef9c2964f31bc63
|
7
|
+
data.tar.gz: 3f1a9b2d21d91452c422cf7e8b8e6dee43b8bf7a84fab897da16ef87a3706cb0831ee02ce991cec93f5628043f0c680329b14bb6729f71bc0155d75747be20a6
|
data/.vscode/launch.json
CHANGED
@@ -25,6 +25,16 @@
|
|
25
25
|
"args": [
|
26
26
|
"${file}"
|
27
27
|
]
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "RSpec - active spec line only",
|
31
|
+
"type": "Ruby",
|
32
|
+
"request": "launch",
|
33
|
+
"cwd": "${workspaceRoot}",
|
34
|
+
"program": "${workspaceRoot}/bin/rspec",
|
35
|
+
"args": [
|
36
|
+
"${file}:${lineNumber}"
|
37
|
+
]
|
28
38
|
}
|
29
39
|
]
|
30
40
|
}
|
data/CHANGELOG.md
CHANGED
@@ -5,7 +5,7 @@ require 'rakuten_web_service/ichiba/product'
|
|
5
5
|
module RakutenWebService
|
6
6
|
module Ichiba
|
7
7
|
class Genre < RakutenWebService::BaseGenre
|
8
|
-
endpoint 'https://app.rakuten.co.jp/services/api/IchibaGenre/Search/
|
8
|
+
endpoint 'https://app.rakuten.co.jp/services/api/IchibaGenre/Search/20140222'
|
9
9
|
|
10
10
|
attribute :genreId, :genreName, :genreLevel, :itemCount
|
11
11
|
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RakutenWebService::BaseGenre do
|
4
|
+
let(:dummy_endpoint) { 'https://api.example.com/dummy_genre' }
|
5
|
+
let(:genre_id) { "1" }
|
6
|
+
let(:expected_response) do
|
7
|
+
{
|
8
|
+
'current' => {
|
9
|
+
dummyGenreId: 1,
|
10
|
+
dummyGenreName: "CurrentGenre",
|
11
|
+
genreLevel: 2
|
12
|
+
},
|
13
|
+
'children' => [
|
14
|
+
{
|
15
|
+
dummyGenreId: 2,
|
16
|
+
dummyGenreName: "ChildOne",
|
17
|
+
genreLevel: 3
|
18
|
+
},
|
19
|
+
{
|
20
|
+
dummyGenreId: 3,
|
21
|
+
dummyGenreName: "ChildTwo",
|
22
|
+
genreLevel: 3
|
23
|
+
}
|
24
|
+
],
|
25
|
+
'parents' => [
|
26
|
+
{
|
27
|
+
dummyGenreId: 0,
|
28
|
+
dummyGenreName: "TopGenre",
|
29
|
+
genreLevel: 1
|
30
|
+
}
|
31
|
+
],
|
32
|
+
'brothers' => [
|
33
|
+
{
|
34
|
+
dummyGenreId: 4,
|
35
|
+
dummyGenreName: "BrotherOne",
|
36
|
+
genreLevel: 1
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
let!(:genre_class) do
|
42
|
+
|
43
|
+
Class.new(RakutenWebService::BaseGenre) do
|
44
|
+
endpoint "https://api.example.com/dummy_genre"
|
45
|
+
set_resource_name 'dummy_genre'
|
46
|
+
root_id 0
|
47
|
+
attribute :dummyGenreId, :dummyGenreName, :genreLevel
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
let!(:expected_request) do
|
52
|
+
stub_request(:get, dummy_endpoint).
|
53
|
+
with(query: {
|
54
|
+
applicationId: "DUMMY_APPLICATION_ID",
|
55
|
+
affiliateId: "DUMMY_AFFILIATE_ID",
|
56
|
+
formatVersion: 2,
|
57
|
+
dummyGenreId: genre_id
|
58
|
+
}).
|
59
|
+
to_return(body: expected_response.to_json)
|
60
|
+
end
|
61
|
+
|
62
|
+
before do
|
63
|
+
RakutenWebService.configure do |c|
|
64
|
+
c.application_id = "DUMMY_APPLICATION_ID"
|
65
|
+
c.affiliate_id = "DUMMY_AFFILIATE_ID"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
after do
|
70
|
+
RakutenWebService::BaseGenre.instance_variable_set(:@repository, {})
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".genre_id_key" do
|
74
|
+
it { expect(genre_class.genre_id_key).to be_eql(:dummy_genre_id) }
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ".root_id" do
|
78
|
+
it { expect(genre_class.root_id).to be_eql(0) }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe ".new" do
|
82
|
+
context "When given string or integer" do
|
83
|
+
specify "should call search" do
|
84
|
+
genre_class.new(genre_id)
|
85
|
+
|
86
|
+
expect(expected_request).to have_been_made.once
|
87
|
+
end
|
88
|
+
|
89
|
+
specify "should call once if the same instance was initialized twice" do
|
90
|
+
2.times { genre_class.new(genre_id) }
|
91
|
+
|
92
|
+
expect(expected_request).to have_been_made.once
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context "When a Hash is given" do
|
97
|
+
subject { genre_class.new(dummyGenreId: 10, dummyGenreName: "NewGenre") }
|
98
|
+
|
99
|
+
specify "API request should not been called" do
|
100
|
+
expect(expected_request).to_not have_been_made
|
101
|
+
end
|
102
|
+
it "shoud respond apropriate attributes" do
|
103
|
+
expect(subject.id).to be_eql(10)
|
104
|
+
expect(subject.name).to be_eql("NewGenre")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe ".[]" do
|
110
|
+
specify "should call search only once as intializing twice" do
|
111
|
+
2.times { genre_class[genre_id] }
|
112
|
+
|
113
|
+
expect(expected_request).to have_been_made.once
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#children" do
|
118
|
+
subject { genre_class.new(genre_id).children }
|
119
|
+
|
120
|
+
it { is_expected.to_not be_empty }
|
121
|
+
|
122
|
+
context "children's children" do
|
123
|
+
before do
|
124
|
+
subject
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should search again" do
|
128
|
+
expect(genre_class).to receive(:search).
|
129
|
+
with(dummy_genre_id: 2).
|
130
|
+
and_return([
|
131
|
+
double(:genre, children: [])
|
132
|
+
])
|
133
|
+
|
134
|
+
expect(subject.first.children).to_not be_nil
|
135
|
+
expect(subject.first.children).to be_empty
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "#parents" do
|
141
|
+
subject { genre_class.new(genre_id).children }
|
142
|
+
|
143
|
+
it { is_expected.to_not be_empty }
|
144
|
+
|
145
|
+
context "children's parents" do
|
146
|
+
before do
|
147
|
+
subject
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should search again" do
|
151
|
+
expect(genre_class).to receive(:search).
|
152
|
+
with(dummy_genre_id: 2).
|
153
|
+
and_return([
|
154
|
+
double(:genre, parents: [])
|
155
|
+
])
|
156
|
+
|
157
|
+
expect(subject.first.parents).to be_empty
|
158
|
+
expect(subject.first.parents).to_not be_nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#brothers" do
|
164
|
+
subject { genre_class.new(genre_id).children }
|
165
|
+
|
166
|
+
it { is_expected.to_not be_empty }
|
167
|
+
|
168
|
+
context "children's brothers" do
|
169
|
+
before do
|
170
|
+
subject
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should search again" do
|
174
|
+
expect(genre_class).to receive(:search).
|
175
|
+
with(dummy_genre_id: 2).
|
176
|
+
and_return([
|
177
|
+
double(:genre, brothers: [])
|
178
|
+
])
|
179
|
+
|
180
|
+
expect(subject.first.brothers).to be_empty
|
181
|
+
expect(subject.first.brothers).to_not be_nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RakutenWebService::Ichiba::Genre do
|
4
|
-
let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaGenre/Search/
|
4
|
+
let(:endpoint) { 'https://app.rakuten.co.jp/services/api/IchibaGenre/Search/20140222' }
|
5
5
|
let(:affiliate_id) { 'dummy_affiliate_id' }
|
6
6
|
let(:application_id) { 'dummy_application_id' }
|
7
7
|
let(:genre_id) { 0 }
|
@@ -13,14 +13,15 @@ describe RakutenWebService::Ichiba::Genre do
|
|
13
13
|
genreId: genre_id
|
14
14
|
}
|
15
15
|
end
|
16
|
+
let(:fixture_file) { 'ichiba/genre_search.json' }
|
16
17
|
let(:expected_json) do
|
17
|
-
JSON.parse(fixture(
|
18
|
+
JSON.parse(fixture(fixture_file))
|
18
19
|
end
|
19
20
|
|
20
21
|
before do
|
21
22
|
@expected_request = stub_request(:get, endpoint).
|
22
23
|
with(query: expected_query).
|
23
|
-
to_return(body: fixture(
|
24
|
+
to_return(body: fixture(fixture_file))
|
24
25
|
|
25
26
|
RakutenWebService.configure do |c|
|
26
27
|
c.affiliate_id = affiliate_id
|
@@ -166,22 +167,16 @@ describe RakutenWebService::Ichiba::Genre do
|
|
166
167
|
end
|
167
168
|
|
168
169
|
describe "#brothers" do
|
169
|
-
let(:genre_id) {
|
170
|
+
let(:genre_id) { 201351 }
|
170
171
|
let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
|
171
|
-
|
172
|
-
before do
|
173
|
-
stub_request(:get, endpoint).with(
|
174
|
-
query: {
|
175
|
-
affiliateId: affiliate_id,
|
176
|
-
aplicationId: application_id,
|
177
|
-
genreId: genre_id
|
178
|
-
}
|
179
|
-
).to_return(body: fixture('ichiba/parents_genre_search.json'))
|
180
|
-
end
|
172
|
+
let(:fixture_file) { 'ichiba/parents_genre_search.json' }
|
181
173
|
|
182
174
|
specify "should respond an array of brother Genres" do
|
183
175
|
expect(genre.brothers).to be_a(Array)
|
184
176
|
end
|
177
|
+
specify "should have some brothers" do
|
178
|
+
expect(genre.brothers).to_not be_empty
|
179
|
+
end
|
185
180
|
end
|
186
181
|
|
187
182
|
describe '#ranking' do
|
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.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- spec/rakuten_web_service/client_spec.rb
|
204
204
|
- spec/rakuten_web_service/configuration_spec.rb
|
205
205
|
- spec/rakuten_web_service/genre_information_spec.rb
|
206
|
+
- spec/rakuten_web_service/genre_spec.rb
|
206
207
|
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
207
208
|
- spec/rakuten_web_service/gora/course_spec.rb
|
208
209
|
- spec/rakuten_web_service/gora/plan_spec.rb
|
@@ -237,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
238
|
version: '0'
|
238
239
|
requirements: []
|
239
240
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.5.2
|
241
242
|
signing_key:
|
242
243
|
specification_version: 4
|
243
244
|
summary: Ruby Client for Rakuten Web Service
|
@@ -275,6 +276,7 @@ test_files:
|
|
275
276
|
- spec/rakuten_web_service/client_spec.rb
|
276
277
|
- spec/rakuten_web_service/configuration_spec.rb
|
277
278
|
- spec/rakuten_web_service/genre_information_spec.rb
|
279
|
+
- spec/rakuten_web_service/genre_spec.rb
|
278
280
|
- spec/rakuten_web_service/gora/course_detail_spec.rb
|
279
281
|
- spec/rakuten_web_service/gora/course_spec.rb
|
280
282
|
- spec/rakuten_web_service/gora/plan_spec.rb
|