rakuten_web_service 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -5
  3. data/CHANGELOG.md +15 -1
  4. data/Gemfile +1 -1
  5. data/README.md +2 -1
  6. data/examples/books_item_search.rb +6 -6
  7. data/examples/gora_search.rb +2 -2
  8. data/examples/ichiba_item_search.rb +1 -1
  9. data/lib/rakuten_web_service/books/genre.rb +1 -1
  10. data/lib/rakuten_web_service/client.rb +4 -0
  11. data/lib/rakuten_web_service/ichiba/genre.rb +1 -1
  12. data/lib/rakuten_web_service/ichiba/shop.rb +1 -1
  13. data/lib/rakuten_web_service/search_result.rb +5 -5
  14. data/lib/rakuten_web_service/version.rb +1 -1
  15. data/spec/rakuten_web_service/books/book_spec.rb +15 -15
  16. data/spec/rakuten_web_service/books/cd_spec.rb +10 -10
  17. data/spec/rakuten_web_service/books/dvd_spec.rb +10 -10
  18. data/spec/rakuten_web_service/books/foreign_book_spec.rb +10 -10
  19. data/spec/rakuten_web_service/books/game_spec.rb +8 -8
  20. data/spec/rakuten_web_service/books/genre_spec.rb +22 -22
  21. data/spec/rakuten_web_service/books/magazine_spec.rb +8 -8
  22. data/spec/rakuten_web_service/books/software_spec.rb +8 -8
  23. data/spec/rakuten_web_service/books/total_spec.rb +5 -5
  24. data/spec/rakuten_web_service/client_spec.rb +19 -19
  25. data/spec/rakuten_web_service/gora/course_detail_spec.rb +4 -4
  26. data/spec/rakuten_web_service/gora/course_spec.rb +7 -7
  27. data/spec/rakuten_web_service/gora/plan_spec.rb +6 -6
  28. data/spec/rakuten_web_service/ichiba/genre_spec.rb +30 -31
  29. data/spec/rakuten_web_service/ichiba/item_spec.rb +24 -24
  30. data/spec/rakuten_web_service/ichiba/product_search_spec.rb +8 -8
  31. data/spec/rakuten_web_service/ichiba/ranking_spec.rb +4 -4
  32. data/spec/rakuten_web_service/ichiba/shop_spec.rb +1 -1
  33. data/spec/rakuten_web_service/kobo/ebook_spec.rb +9 -9
  34. data/spec/rakuten_web_service/kobo/genre_spec.rb +9 -9
  35. data/spec/rakuten_web_service/recipe/category_spec.rb +3 -3
  36. data/spec/rakuten_web_service/recipe_spec.rb +3 -3
  37. data/spec/spec_helper.rb +6 -3
  38. metadata +2 -3
  39. data/.coveralls.yml +0 -1
@@ -7,9 +7,9 @@ describe RakutenWebService::Ichiba::Genre do
7
7
  let(:genre_id) { 0 }
8
8
  let(:expected_query) do
9
9
  {
10
- :affiliateId => affiliate_id,
11
- :applicationId => application_id,
12
- :genreId => genre_id
10
+ affiliateId: affiliate_id,
11
+ applicationId: application_id,
12
+ genreId: genre_id
13
13
  }
14
14
  end
15
15
  let(:expected_json) do
@@ -18,8 +18,8 @@ describe RakutenWebService::Ichiba::Genre do
18
18
 
19
19
  before do
20
20
  @expected_request = stub_request(:get, endpoint).
21
- with(:query => expected_query).
22
- to_return(:body => fixture('ichiba/genre_search.json'))
21
+ with(query: expected_query).
22
+ to_return(body: fixture('ichiba/genre_search.json'))
23
23
 
24
24
  RakutenWebService.configure do |c|
25
25
  c.affiliate_id = affiliate_id
@@ -30,7 +30,7 @@ describe RakutenWebService::Ichiba::Genre do
30
30
  describe '.search' do
31
31
 
32
32
  before do
33
- @genre = RakutenWebService::Ichiba::Genre.search(:genreId => genre_id).first
33
+ @genre = RakutenWebService::Ichiba::Genre.search(genreId: genre_id).first
34
34
  end
35
35
 
36
36
  subject { @genre }
@@ -50,8 +50,8 @@ describe RakutenWebService::Ichiba::Genre do
50
50
  end
51
51
 
52
52
  describe '.new' do
53
- before do
54
- RakutenWebService::Ichiba::Genre.search(:genreId => genre_id).first
53
+ before do
54
+ RakutenWebService::Ichiba::Genre.search(genreId: genre_id).first
55
55
  end
56
56
 
57
57
  context 'given genre_id' do
@@ -76,15 +76,14 @@ describe RakutenWebService::Ichiba::Genre do
76
76
  let(:new_genre_id) { 1981 }
77
77
  before do
78
78
  @expected_request = stub_request(:get, endpoint).
79
- with(:query => {
80
- :affiliateId => affiliate_id,
81
- :applicationId => application_id,
82
- :genreId => new_genre_id }).
83
- to_return(:body => {:current =>
84
- { :genreId => new_genre_id,
85
- :genreName => 'DummyGenre',
86
- :genreLevel => 3 }
87
- }.to_json)
79
+ with(query: {
80
+ affiliateId: affiliate_id,
81
+ applicationId: application_id,
82
+ genreId: new_genre_id }).
83
+ to_return(body: {current: { genreId: new_genre_id,
84
+ genreName: 'DummyGenre',
85
+ genreLevel: 3 }
86
+ }.to_json)
88
87
 
89
88
  @genre = RakutenWebService::Ichiba::Genre.new(new_genre_id)
90
89
  end
@@ -121,14 +120,14 @@ describe RakutenWebService::Ichiba::Genre do
121
120
 
122
121
  before do
123
122
  @additional_request = stub_request(:get, endpoint).
124
- with(:query => {
125
- :affiliateId => affiliate_id,
126
- :applicationId => application_id,
127
- :genreId => target_genre['genreId']
128
- }).to_return(:body => {
129
- :current => target_genre,
130
- :children => []
131
- }.to_json)
123
+ with(query: {
124
+ affiliateId: affiliate_id,
125
+ applicationId: application_id,
126
+ genreId: target_genre['genreId']
127
+ }).to_return(body: {
128
+ current: target_genre,
129
+ children: []
130
+ }.to_json)
132
131
  end
133
132
 
134
133
  subject { root_genre.children.first }
@@ -164,12 +163,12 @@ describe RakutenWebService::Ichiba::Genre do
164
163
  let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
165
164
 
166
165
  before do
167
- stub_request(:get, endpoint).with(:query => expected_query).
168
- to_return(:body => fixture('ichiba/genre_search.json'))
166
+ stub_request(:get, endpoint).with(query: expected_query).
167
+ to_return(body: fixture('ichiba/genre_search.json'))
169
168
  end
170
169
 
171
170
  specify "should call RankingItem's search with genre_id option" do
172
- expect(RakutenWebService::Ichiba::RankingItem).to receive(:search).with(:genre_id => genre_id)
171
+ expect(RakutenWebService::Ichiba::RankingItem).to receive(:search).with(genre_id: genre_id)
173
172
  expect { genre.ranking }.to_not raise_error
174
173
  end
175
174
  specify "should call RankingItem's search with genre_id and given options" do
@@ -182,12 +181,12 @@ describe RakutenWebService::Ichiba::Genre do
182
181
  let(:genre) { RakutenWebService::Ichiba::Genre.new(genre_id) }
183
182
 
184
183
  before do
185
- stub_request(:get, endpoint).with(:query => expected_query).
186
- to_return(:body => fixture('ichiba/genre_search.json'))
184
+ stub_request(:get, endpoint).with(query: expected_query).
185
+ to_return(body: fixture('ichiba/genre_search.json'))
187
186
  end
188
187
 
189
188
  specify "should call Product search with genre_id option" do
190
- expect(RakutenWebService::Ichiba::Product).to receive(:search).with(:genre_id => genre_id)
189
+ expect(RakutenWebService::Ichiba::Product).to receive(:search).with(genre_id: genre_id)
191
190
  expect { genre.products }.to_not raise_error
192
191
  end
193
192
  end
@@ -6,9 +6,9 @@ describe RakutenWebService::Ichiba::Item do
6
6
  let(:application_id) { 'dummy_application_id' }
7
7
  let(:expected_query) do
8
8
  {
9
- :affiliateId => affiliate_id,
10
- :applicationId => application_id,
11
- :keyword => 'Ruby'
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ keyword: 'Ruby'
12
12
  }
13
13
  end
14
14
 
@@ -23,20 +23,20 @@ describe RakutenWebService::Ichiba::Item do
23
23
  before do
24
24
  response = JSON.parse(fixture('ichiba/item_search_with_keyword_Ruby.json'))
25
25
  @expected_request = stub_request(:get, endpoint).
26
- with(:query => expected_query).to_return(:body => response.to_json)
26
+ with(query: expected_query).to_return(body: response.to_json)
27
27
 
28
28
  response['page'] = 2
29
29
  response['first'] = 31
30
30
  response['last'] = 60
31
31
  response['pageCount'] = 2
32
32
  @second_request = stub_request(:get, endpoint).
33
- with(:query => expected_query.merge(:page => 2)).
34
- to_return(:body => response.to_json)
33
+ with(query: expected_query.merge(page: 2)).
34
+ to_return(body: response.to_json)
35
35
  end
36
36
 
37
37
  context 'just call the search method' do
38
38
  before do
39
- @items = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby')
39
+ @items = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby')
40
40
  end
41
41
 
42
42
  specify 'endpoint should not be called' do
@@ -55,7 +55,7 @@ describe RakutenWebService::Ichiba::Item do
55
55
  specify 'shoud be access by key' do
56
56
  expect(subject['itemName']).to eq(expected_json['itemName'])
57
57
  expect(subject['item_name']).to eq(expected_json['itemName'])
58
- end
58
+ end
59
59
 
60
60
  describe '#name' do
61
61
  subject { super().name }
@@ -79,7 +79,7 @@ describe RakutenWebService::Ichiba::Item do
79
79
 
80
80
  context 'chain calling' do
81
81
  before do
82
- @items2 = @items.search(:keyword => 'Go')
82
+ @items2 = @items.search(keyword: 'Go')
83
83
  end
84
84
 
85
85
  specify "2 search resutls should be independent" do
@@ -111,7 +111,7 @@ describe RakutenWebService::Ichiba::Item do
111
111
  end
112
112
 
113
113
  context 'When TooManyRequest error raised' do
114
- let(:client) do
114
+ let(:client) do
115
115
  c = double('client')
116
116
  allow(c).to receive(:get).and_raise(RWS::TooManyRequests)
117
117
  c
@@ -133,22 +133,22 @@ describe RakutenWebService::Ichiba::Item do
133
133
  before do
134
134
  response = JSON.parse(fixture('ichiba/item_search_with_keyword_Ruby.json'))
135
135
  @expected_request = stub_request(:get, endpoint).
136
- with(:query => expected_query).to_return(:body => response.to_json)
136
+ with(query: expected_query).to_return(body: response.to_json)
137
137
 
138
138
  response['page'] = 2
139
139
  response['first'] = 31
140
140
  response['last'] = 60
141
141
  response['pageCount'] = 2
142
142
  @second_request = stub_request(:get, endpoint).
143
- with(:query => expected_query.merge(:page => 2)).
144
- to_return(:body => response.to_json)
143
+ with(query: expected_query.merge(page: 2)).
144
+ to_return(body: response.to_json)
145
145
  end
146
146
 
147
147
  context 'When givne a block' do
148
148
  specify '' do
149
- expect { |b| RWS::Ichiba::Item.all({:keyword => 'Ruby'}, &b) }.to yield_control.exactly(60).times
149
+ expect { |b| RWS::Ichiba::Item.all({keyword: 'Ruby'}, &b) }.to yield_control.exactly(60).times
150
150
 
151
- expect { |b| RWS::Ichiba::Item.all({:keyword => 'Ruby'}, &b) }.to yield_successive_args(*([RakutenWebService::Ichiba::Item] * 60))
151
+ expect { |b| RWS::Ichiba::Item.all({keyword: 'Ruby'}, &b) }.to yield_successive_args(*([RakutenWebService::Ichiba::Item] * 60))
152
152
  end
153
153
  end
154
154
  end
@@ -175,14 +175,14 @@ describe RakutenWebService::Ichiba::Item do
175
175
  let(:response) { JSON.parse(fixture('ichiba/item_search_with_keyword_Ruby.json')) }
176
176
 
177
177
  before do
178
- stub_request(:get, endpoint).with(:query => expected_query).
179
- to_return(:body => response.to_json)
178
+ stub_request(:get, endpoint).with(query: expected_query).
179
+ to_return(body: response.to_json)
180
180
 
181
181
  expected_item = response['Items'][0]['Item']
182
- expect(RakutenWebService::Ichiba::Genre).to receive('new').with(expected_item['genreId'])
182
+ expect(RakutenWebService::Ichiba::Genre).to receive('new').with(expected_item['genreId'])
183
183
  end
184
184
 
185
- subject { RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby').first.genre }
185
+ subject { RakutenWebService::Ichiba::Item.search(keyword: 'Ruby').first.genre }
186
186
 
187
187
  specify 'respond Genre object' do
188
188
  expect { subject }.to_not raise_error
@@ -194,12 +194,12 @@ describe RakutenWebService::Ichiba::Item do
194
194
  let(:expected_item) { response['Items'][0]['Item'] }
195
195
 
196
196
  before do
197
- stub_request(:get, endpoint).with(:query => expected_query).
198
- to_return(:body => response.to_json)
197
+ stub_request(:get, endpoint).with(query: expected_query).
198
+ to_return(body: response.to_json)
199
199
  end
200
200
 
201
201
  subject do
202
- RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby').first.shop
202
+ RakutenWebService::Ichiba::Item.search(keyword: 'Ruby').first.shop
203
203
  end
204
204
 
205
205
  specify 'responds Shop object' do
@@ -212,13 +212,13 @@ describe RakutenWebService::Ichiba::Item do
212
212
 
213
213
  describe '#order' do
214
214
  specify 'convert sort parameter' do
215
- query = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby').order(affiliate_rate: :desc)
215
+ query = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby').order(affiliate_rate: :desc)
216
216
 
217
217
  expect(query.params[:sort]).to eq('-affiliateRate')
218
218
  end
219
219
 
220
220
  specify 'reproduces new SearchResult object' do
221
- first_query = RakutenWebService::Ichiba::Item.search(:keyword => 'Ruby')
221
+ first_query = RakutenWebService::Ichiba::Item.search(keyword: 'Ruby')
222
222
  second_query = first_query.order(affiliate_rate: :desc)
223
223
 
224
224
  expect(first_query.params[:sort]).to be_nil
@@ -6,9 +6,9 @@ describe RakutenWebService::Ichiba::Product do
6
6
  let(:application_id) { 'dummy_application_id' }
7
7
  let(:expected_query) do
8
8
  {
9
- :affiliateId => affiliate_id,
10
- :applicationId => application_id,
11
- :keyword => 'Ruby'
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ keyword: 'Ruby'
12
12
  }
13
13
  end
14
14
 
@@ -23,18 +23,18 @@ describe RakutenWebService::Ichiba::Product do
23
23
  before do
24
24
  response = JSON.parse(fixture('ichiba/product_search.json'))
25
25
  @expected_request = stub_request(:get, endpoint).
26
- with(:query => expected_query).to_return(:body => response.to_json)
26
+ with(query: expected_query).to_return(body: response.to_json)
27
27
 
28
28
  response['page'] = 2
29
29
  response['first'] = 31
30
30
  response['last'] = 60
31
31
  response['pageCount'] = 2
32
32
  @second_request = stub_request(:get, endpoint).
33
- with(:query => expected_query.merge(:page => 2)).
34
- to_return(:body => response.to_json)
33
+ with(query: expected_query.merge(page: 2)).
34
+ to_return(body: response.to_json)
35
35
  end
36
36
 
37
- subject { RakutenWebService::Ichiba::Product.search(:keyword => 'Ruby') }
37
+ subject { RakutenWebService::Ichiba::Product.search(keyword: 'Ruby') }
38
38
 
39
39
  specify '' do
40
40
  expect(subject.count).to eq(30)
@@ -44,7 +44,7 @@ describe RakutenWebService::Ichiba::Product do
44
44
  let(:expected_product) do
45
45
  JSON.parse(fixture('ichiba/product_search.json'))['Products'].first['Product']
46
46
  end
47
- let(:product) { RakutenWebService::Ichiba::Product.search(:keyword => 'Ruby').first }
47
+ let(:product) { RakutenWebService::Ichiba::Product.search(keyword: 'Ruby').first }
48
48
 
49
49
  specify 'should have methods to respond keys following with "product"' do
50
50
  expect(product.id).to eq(expected_product['productId'])
@@ -7,14 +7,14 @@ describe RakutenWebService::Ichiba::RankingItem do
7
7
  let(:application_id) { 'application_id' }
8
8
  let(:expected_query) do
9
9
  {
10
- :affiliateId => affiliate_id, :applicationId => application_id
10
+ affiliateId: affiliate_id, applicationId: application_id
11
11
  }
12
12
  end
13
13
 
14
- before do
14
+ before do
15
15
  response = JSON.parse(fixture('ichiba/ranking_search.json'))
16
16
  @expected_request = stub_request(:get, endpoint).
17
- with(:query => expected_query).to_return(:body => response.to_json)
17
+ with(query: expected_query).to_return(body: response.to_json)
18
18
 
19
19
  RakutenWebService.configure do |c|
20
20
  c.affiliate_id = affiliate_id
@@ -28,7 +28,7 @@ describe RakutenWebService::Ichiba::RankingItem do
28
28
  response['Items'][0]['Item']
29
29
  end
30
30
 
31
- before do
31
+ before do
32
32
  @ranking_item = RakutenWebService::Ichiba::RankingItem.search({}).first
33
33
  end
34
34
 
@@ -40,7 +40,7 @@ describe RakutenWebService::Ichiba::Shop do
40
40
 
41
41
  before do
42
42
  @expected_request = stub_request(:get, endpoint).
43
- with(:query => expected_query).to_return(:body => response.to_json)
43
+ with(query: expected_query).to_return(body: response.to_json)
44
44
  end
45
45
 
46
46
  specify 'call the endpoint with the shopCode' do
@@ -6,9 +6,9 @@ describe RakutenWebService::Kobo::Ebook do
6
6
  let(:application_id) { 'dummy_application_id' }
7
7
  let(:expected_query) do
8
8
  {
9
- :affiliateId => affiliate_id,
10
- :applicationId => application_id,
11
- :title => 'Ruby'
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ title: 'Ruby'
12
12
  }
13
13
  end
14
14
 
@@ -23,11 +23,11 @@ describe RakutenWebService::Kobo::Ebook do
23
23
  before do
24
24
  response = JSON.parse(fixture('kobo/ebook_search_with_Ruby.json'))
25
25
  @expected_request = stub_request(:get, endpoint).
26
- with(:query => expected_query).to_return(:body => response.to_json)
26
+ with(query: expected_query).to_return(body: response.to_json)
27
27
  end
28
28
 
29
29
  specify 'call endpoint when accessing results' do
30
- ebooks = RakutenWebService::Kobo::Ebook.search(:title => 'Ruby')
30
+ ebooks = RakutenWebService::Kobo::Ebook.search(title: 'Ruby')
31
31
  expect(@expected_request).to_not have_been_made
32
32
 
33
33
  ebook = ebooks.first
@@ -40,7 +40,7 @@ describe RakutenWebService::Kobo::Ebook do
40
40
  before do
41
41
  response = JSON.parse(fixture('kobo/ebook_search_with_Ruby.json'))
42
42
  stub_request(:get, endpoint).
43
- with(:query => expected_query).to_return(:body => response.to_json)
43
+ with(query: expected_query).to_return(body: response.to_json)
44
44
  end
45
45
 
46
46
  subject { RakutenWebService::Kobo::Ebook.search(title: 'Ruby') }
@@ -63,13 +63,13 @@ describe RakutenWebService::Kobo::Ebook do
63
63
  let(:response) { JSON.parse(fixture('kobo/ebook_search_with_Ruby.json')) }
64
64
 
65
65
  specify 'respond Kobo::Genre object' do
66
- stub_request(:get, endpoint).with(:query => expected_query).
67
- to_return(:body => response.to_json)
66
+ stub_request(:get, endpoint).with(query: expected_query).
67
+ to_return(body: response.to_json)
68
68
 
69
69
  expected_item = response['Items'][0]['Item']
70
70
  expect(RakutenWebService::Kobo::Genre).to receive('new').with(expected_item['koboGenreId'])
71
71
 
72
- RakutenWebService::Kobo::Ebook.search(:title => 'Ruby').first.genre
72
+ RakutenWebService::Kobo::Ebook.search(title: 'Ruby').first.genre
73
73
  end
74
74
  end
75
75
  end
@@ -7,9 +7,9 @@ describe RWS::Kobo::Genre do
7
7
  let(:genre_id) { '101' }
8
8
  let(:expected_query) do
9
9
  {
10
- :affiliateId => affiliate_id,
11
- :applicationId => application_id,
12
- :koboGenreId => genre_id
10
+ affiliateId: affiliate_id,
11
+ applicationId: application_id,
12
+ koboGenreId: genre_id
13
13
  }
14
14
  end
15
15
  let(:expected_json) do
@@ -18,8 +18,8 @@ describe RWS::Kobo::Genre do
18
18
 
19
19
  before do
20
20
  @expected_request = stub_request(:get, endpoint).
21
- with(:query => expected_query).
22
- to_return(:body => expected_json.to_json)
21
+ with(query: expected_query).
22
+ to_return(body: expected_json.to_json)
23
23
 
24
24
  RakutenWebService.configure do |c|
25
25
  c.affiliate_id = affiliate_id
@@ -29,7 +29,7 @@ describe RWS::Kobo::Genre do
29
29
 
30
30
  describe '.search' do
31
31
  before do
32
- @genre = RWS::Kobo::Genre.search(:koboGenreId => genre_id).first
32
+ @genre = RWS::Kobo::Genre.search(koboGenreId: genre_id).first
33
33
  end
34
34
 
35
35
  specify 'call the endpoint once' do
@@ -39,8 +39,8 @@ describe RWS::Kobo::Genre do
39
39
 
40
40
  describe '#search' do
41
41
  before do
42
- stub_request(:get, endpoint).with(:query => expected_query).
43
- to_return(:body => expected_json.to_json)
42
+ stub_request(:get, endpoint).with(query: expected_query).
43
+ to_return(body: expected_json.to_json)
44
44
  end
45
45
 
46
46
  context 'Without arguments' do
@@ -53,7 +53,7 @@ describe RWS::Kobo::Genre do
53
53
  context 'With arguments' do
54
54
  specify 'should call RWS::Kobo::Ebook.search with given arguments and genre id' do
55
55
  options = { title: 'Ruby' }
56
- expect(RWS::Kobo::Ebook).to receive(:search).with(:title => 'Ruby', RWS::Kobo::Genre.genre_id_key => genre_id)
56
+ expect(RWS::Kobo::Ebook).to receive(:search).with(title: 'Ruby', RWS::Kobo::Genre.genre_id_key => genre_id)
57
57
 
58
58
  RWS::Kobo::Genre.root.search(options)
59
59
  end
@@ -6,9 +6,9 @@ describe RakutenWebService::Recipe::Category do
6
6
  let(:application_id) { 'dummy_application_id' }
7
7
  let(:expected_query) do
8
8
  {
9
- :affiliateId => affiliate_id,
10
- :applicationId => application_id,
11
- :categoryType => category_type
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ categoryType: category_type
12
12
  }
13
13
  end
14
14