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
@@ -6,9 +6,9 @@ describe RakutenWebService::Books::Game 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,11 +23,11 @@ describe RakutenWebService::Books::Game do
23
23
  before do
24
24
  response = JSON.parse(fixture('books/game_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
  end
28
28
 
29
29
  specify 'call endpoint when accessing results' do
30
- games = RakutenWebService::Books::Game.search(:keyword => 'Ruby')
30
+ games = RakutenWebService::Books::Game.search(keyword: 'Ruby')
31
31
  expect(@expected_request).to_not have_been_made
32
32
 
33
33
  game = games.first
@@ -38,13 +38,13 @@ describe RakutenWebService::Books::Game do
38
38
 
39
39
  context 'When using Books::Total.search' do
40
40
  let(:game) do
41
- RWS::Books::Game.new(:jan => '12345')
41
+ RWS::Books::Game.new(jan: '12345')
42
42
  end
43
43
 
44
44
  before do
45
45
  @expected_request = stub_request(:get, endpoint).
46
- with(:query => { :affiliateId => affiliate_id, :applicationId => application_id, :jan => '12345' }).
47
- to_return(:body => { :Items => [ { :Item => { :title => 'foo' } } ] }.to_json)
46
+ with(query: { affiliateId: affiliate_id, applicationId: application_id, jan: '12345' }).
47
+ to_return(body: { Items: [ { Item: { title: 'foo' } } ] }.to_json)
48
48
  end
49
49
 
50
50
  specify 'retrieves automatically if accessing the value of lack attribute' do
@@ -7,9 +7,9 @@ describe RWS::Books::Genre do
7
7
  let(:genre_id) { '000' }
8
8
  let(:expected_query) do
9
9
  {
10
- :affiliateId => affiliate_id,
11
- :applicationId => application_id,
12
- :booksGenreId => genre_id
10
+ affiliateId: affiliate_id,
11
+ applicationId: application_id,
12
+ booksGenreId: genre_id
13
13
  }
14
14
  end
15
15
  let(:expected_json) do
@@ -22,8 +22,8 @@ describe RWS::Books::Genre do
22
22
 
23
23
  before do
24
24
  @expected_request = stub_request(:get, endpoint).
25
- with(:query => expected_query).
26
- to_return(:body => expected_json.to_json)
25
+ with(query: expected_query).
26
+ to_return(body: expected_json.to_json)
27
27
 
28
28
  RakutenWebService.configure do |c|
29
29
  c.affiliate_id = affiliate_id
@@ -33,7 +33,7 @@ describe RWS::Books::Genre do
33
33
 
34
34
  describe '.search' do
35
35
  before do
36
- @genre = RWS::Books::Genre.search(:booksGenreId => genre_id).first
36
+ @genre = RWS::Books::Genre.search(booksGenreId: genre_id).first
37
37
  end
38
38
 
39
39
  specify 'call the endpoint once' do
@@ -57,11 +57,11 @@ describe RWS::Books::Genre do
57
57
  let(:genre_id) { '007' }
58
58
  let(:expected_json) do
59
59
  {
60
- :current => {
61
- :booksGenreId => genre_id,
62
- :booksGenreName => 'DummyGenre',
63
- :genreLevel => '2'
64
- }
60
+ current: {
61
+ booksGenreId: genre_id,
62
+ booksGenreName: 'DummyGenre',
63
+ genreLevel: '2'
64
+ }
65
65
  }
66
66
  end
67
67
 
@@ -91,7 +91,7 @@ describe RWS::Books::Genre do
91
91
  describe '#children' do
92
92
  context 'When get search method' do
93
93
  before do
94
- @genre = RWS::Books::Genre.search(:booksGenreId => genre_id).first
94
+ @genre = RWS::Books::Genre.search(booksGenreId: genre_id).first
95
95
  end
96
96
 
97
97
  specify 'are Books::Genre objects' do
@@ -104,7 +104,7 @@ describe RWS::Books::Genre do
104
104
 
105
105
  context 'when the genre object has no children information' do
106
106
  specify 'call the endpoint to get children' do
107
- genre = RWS::Books::Genre.new(:booksGenreId => genre_id)
107
+ genre = RWS::Books::Genre.new(booksGenreId: genre_id)
108
108
  genre.children
109
109
 
110
110
  expect(@expected_request).to have_been_made.once
@@ -114,14 +114,14 @@ describe RWS::Books::Genre do
114
114
 
115
115
  describe '#search' do
116
116
  before do
117
- @genre = RWS::Books::Genre.new(:booksGenreId => genre_id)
117
+ @genre = RWS::Books::Genre.new(booksGenreId: genre_id)
118
118
  end
119
119
 
120
120
  context 'if the genre_id starts with "001"' do
121
121
  let(:genre_id) { '001001' }
122
122
 
123
123
  specify 'delegate Books::Book.search' do
124
- expect(RWS::Books::Book).to receive(:search).with(:booksGenreId => genre_id)
124
+ expect(RWS::Books::Book).to receive(:search).with(booksGenreId: genre_id)
125
125
 
126
126
  @genre.search
127
127
  end
@@ -131,7 +131,7 @@ describe RWS::Books::Genre do
131
131
  let(:genre_id) { '002101' }
132
132
 
133
133
  specify 'delegate Books::CD.search' do
134
- expect(RWS::Books::CD).to receive(:search).with(:booksGenreId => genre_id)
134
+ expect(RWS::Books::CD).to receive(:search).with(booksGenreId: genre_id)
135
135
 
136
136
  @genre.search
137
137
  end
@@ -141,7 +141,7 @@ describe RWS::Books::Genre do
141
141
  let(:genre_id) { '003201' }
142
142
 
143
143
  specify 'delegate Books::DVD.search' do
144
- expect(RWS::Books::DVD).to receive(:search).with(:booksGenreId => genre_id)
144
+ expect(RWS::Books::DVD).to receive(:search).with(booksGenreId: genre_id)
145
145
 
146
146
  @genre.search
147
147
  end
@@ -151,7 +151,7 @@ describe RWS::Books::Genre do
151
151
  let(:genre_id) { '004301' }
152
152
 
153
153
  specify 'delegate Books::Software.search' do
154
- expect(RWS::Books::Software).to receive(:search).with(:booksGenreId => genre_id)
154
+ expect(RWS::Books::Software).to receive(:search).with(booksGenreId: genre_id)
155
155
 
156
156
  @genre.search
157
157
  end
@@ -161,7 +161,7 @@ describe RWS::Books::Genre do
161
161
  let(:genre_id) { '005401' }
162
162
 
163
163
  specify 'delegate Books::ForeignBook.search' do
164
- expect(RWS::Books::ForeignBook).to receive(:search).with(:booksGenreId => genre_id)
164
+ expect(RWS::Books::ForeignBook).to receive(:search).with(booksGenreId: genre_id)
165
165
 
166
166
  @genre.search
167
167
  end
@@ -171,17 +171,17 @@ describe RWS::Books::Genre do
171
171
  let(:genre_id) { '006501' }
172
172
 
173
173
  specify 'delegate Books::Game.search' do
174
- expect(RWS::Books::Game).to receive(:search).with(:booksGenreId => genre_id)
174
+ expect(RWS::Books::Game).to receive(:search).with(booksGenreId: genre_id)
175
175
 
176
176
  @genre.search
177
177
  end
178
178
  end
179
-
179
+
180
180
  context 'if the genre_id starts with "007"' do
181
181
  let(:genre_id) { '007601' }
182
182
 
183
183
  specify 'delegate Books::Magazine.search' do
184
- expect(RWS::Books::Magazine).to receive(:search).with(:booksGenreId => genre_id)
184
+ expect(RWS::Books::Magazine).to receive(:search).with(booksGenreId: genre_id)
185
185
 
186
186
  @genre.search
187
187
  end
@@ -6,9 +6,9 @@ describe RakutenWebService::Books::Magazine 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,11 +23,11 @@ describe RakutenWebService::Books::Magazine do
23
23
  before do
24
24
  response = JSON.parse(fixture('books/magazine_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
  end
28
28
 
29
29
  specify 'call endpoint when accessing results' do
30
- magazines = RakutenWebService::Books::Magazine.search(:keyword => 'Ruby')
30
+ magazines = RakutenWebService::Books::Magazine.search(keyword: 'Ruby')
31
31
  expect(@expected_request).to_not have_been_made
32
32
 
33
33
  magazine = magazines.first
@@ -38,13 +38,13 @@ describe RakutenWebService::Books::Magazine do
38
38
 
39
39
  context 'When using Books::Total.search' do
40
40
  let(:magazine) do
41
- RWS::Books::Magazine.new(:jan => '12345')
41
+ RWS::Books::Magazine.new(jan: '12345')
42
42
  end
43
43
 
44
44
  before do
45
45
  @expected_request = stub_request(:get, endpoint).
46
- with(:query => { :affiliateId => affiliate_id, :applicationId => application_id, :jan => '12345' }).
47
- to_return(:body => { :Items => [ { :Item => { :title => 'foo' } } ] }.to_json)
46
+ with(query: { affiliateId: affiliate_id, applicationId: application_id, jan: '12345' }).
47
+ to_return(body: { Items: [ { Item: { title: 'foo' } } ] }.to_json)
48
48
  end
49
49
 
50
50
  specify 'retrieves automatically if accessing the value of lack attribute' do
@@ -6,9 +6,9 @@ describe RakutenWebService::Books::Software 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,11 +23,11 @@ describe RakutenWebService::Books::Software do
23
23
  before do
24
24
  response = JSON.parse(fixture('books/software_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
  end
28
28
 
29
29
  specify 'call endpoint when accessing results' do
30
- softwares = RakutenWebService::Books::Software.search(:keyword => 'Ruby')
30
+ softwares = RakutenWebService::Books::Software.search(keyword: 'Ruby')
31
31
  expect(@expected_request).to_not have_been_made
32
32
 
33
33
  software = softwares.first
@@ -38,13 +38,13 @@ describe RakutenWebService::Books::Software do
38
38
 
39
39
  context 'When using Books::Total.search' do
40
40
  let(:software) do
41
- RWS::Books::Software.new(:jan => '12345')
41
+ RWS::Books::Software.new(jan: '12345')
42
42
  end
43
43
 
44
44
  before do
45
45
  @expected_request = stub_request(:get, endpoint).
46
- with(:query => { :affiliateId => affiliate_id, :applicationId => application_id, :jan => '12345' }).
47
- to_return(:body => { :Items => [ { :Item => { :title => 'foo' } } ] }.to_json)
46
+ with(query: { affiliateId: affiliate_id, applicationId: application_id, jan: '12345' }).
47
+ to_return(body: { Items: [ { Item: { title: 'foo' } } ] }.to_json)
48
48
  end
49
49
 
50
50
  specify 'retrieves automatically if accessing the value of lack attribute' do
@@ -6,9 +6,9 @@ describe RakutenWebService::Books::Total 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,11 +23,11 @@ describe RakutenWebService::Books::Total do
23
23
  before do
24
24
  response = JSON.parse(fixture('books/total_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
  end
28
28
 
29
29
  specify 'call endpoint when accessing results' do
30
- items = RakutenWebService::Books::Total.search(:keyword => 'Ruby')
30
+ items = RakutenWebService::Books::Total.search(keyword: 'Ruby')
31
31
  expect(@expected_request).to_not have_been_made
32
32
 
33
33
  item = items.first
@@ -9,10 +9,10 @@ describe RakutenWebService::Client do
9
9
  let(:application_id) { 'default_application_id' }
10
10
  let(:affiliate_id) { 'default_affiliate_id' }
11
11
  let(:expected_query) do
12
- { :affiliateId => affiliate_id, :applicationId => application_id }
12
+ { affiliateId: affiliate_id, applicationId: application_id }
13
13
  end
14
14
  let(:expected_response) do
15
- { :body => '{"status":"ok"}' }
15
+ { body: '{"status":"ok"}' }
16
16
  end
17
17
 
18
18
  before do
@@ -43,8 +43,8 @@ describe RakutenWebService::Client do
43
43
  let(:application_id) { 'latest_application_id' }
44
44
 
45
45
  before do
46
- client.get(:affiliate_id => affiliate_id,
47
- :application_id => application_id)
46
+ client.get(affiliate_id: affiliate_id,
47
+ application_id: application_id)
48
48
  end
49
49
 
50
50
  specify 'call endpoint with given parameters' do
@@ -85,9 +85,9 @@ describe RakutenWebService::Client do
85
85
  describe 'about exceptions' do
86
86
  context 'parameter error' do
87
87
  let(:expected_response) do
88
- { :status => 400,
89
- :body => '{"error": "wrong_parameter",
90
- "error_description": "specify valid applicationId"}'
88
+ { status: 400,
89
+ body: '{"error": "wrong_parameter",
90
+ "error_description": "specify valid applicationId"}'
91
91
  }
92
92
  end
93
93
 
@@ -99,9 +99,9 @@ describe RakutenWebService::Client do
99
99
 
100
100
  context 'Too many requests' do
101
101
  let(:expected_response) do
102
- { :status => 429,
103
- :body => '{ "error": "too_many_requests",
104
- "error_description": "number of allowed requests has been exceeded for this API. please try again soon." }'
102
+ { status: 429,
103
+ body: '{ "error": "too_many_requests",
104
+ "error_description": "number of allowed requests has been exceeded for this API. please try again soon." }'
105
105
  }
106
106
  end
107
107
 
@@ -113,9 +113,9 @@ describe RakutenWebService::Client do
113
113
 
114
114
  context 'Internal error in Rakuten Web Service' do
115
115
  let(:expected_response) do
116
- { :status => 500,
117
- :body => '{ "error": "system_error",
118
- "error_description": "api logic error" }'
116
+ { status: 500,
117
+ body: '{ "error": "system_error",
118
+ "error_description": "api logic error" }'
119
119
  }
120
120
  end
121
121
 
@@ -126,9 +126,9 @@ describe RakutenWebService::Client do
126
126
 
127
127
  context 'Unavaiable due to maintainance or overloaded' do
128
128
  let(:expected_response) do
129
- { :status => 503,
130
- :body => '{ "error": "service_unavailable",
131
- "error_description": "XXX/XXX is under maintenance" }'
129
+ { status: 503,
130
+ body: '{ "error": "service_unavailable",
131
+ "error_description": "XXX/XXX is under maintenance" }'
132
132
  }
133
133
  end
134
134
 
@@ -139,9 +139,9 @@ describe RakutenWebService::Client do
139
139
 
140
140
  context 'The specified genre has no ranking data' do
141
141
  let(:expected_response) do
142
- { :status => 404,
143
- :body => '{ "error": "not_found",
144
- "error_description": "This genre data does not exist"}'
142
+ { status: 404,
143
+ body: '{ "error": "not_found",
144
+ "error_description": "This genre data does not exist"}'
145
145
  }
146
146
  end
147
147
 
@@ -6,9 +6,9 @@ describe RakutenWebService::Gora::CourseDetail 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
- :golfCourseId => 120092
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ golfCourseId: 120092
12
12
  }
13
13
  end
14
14
 
@@ -23,7 +23,7 @@ describe RakutenWebService::Gora::CourseDetail do
23
23
  before do
24
24
  response = JSON.parse(fixture('gora/course_detail_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
  end
28
28
 
29
29
  context 'call the find method' do
@@ -6,9 +6,9 @@ describe RakutenWebService::Gora::Course 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 => '軽井沢'
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ keyword: '軽井沢'
12
12
  }
13
13
  end
14
14
 
@@ -23,19 +23,19 @@ describe RakutenWebService::Gora::Course do
23
23
  before do
24
24
  response = JSON.parse(fixture('gora/course_search_with_Karuizawa.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
  @second_request = stub_request(:get, endpoint).
32
- with(:query => expected_query.merge(:page => 2)).
33
- to_return(:body => response.to_json)
32
+ with(query: expected_query.merge(page: 2)).
33
+ to_return(body: response.to_json)
34
34
  end
35
35
 
36
36
  context 'just call the search method' do
37
37
  before do
38
- @courses = RakutenWebService::Gora::Course.search(:keyword => '軽井沢')
38
+ @courses = RakutenWebService::Gora::Course.search(keyword: '軽井沢')
39
39
  end
40
40
 
41
41
  specify 'endpoint should not be called' do
@@ -6,10 +6,10 @@ describe RakutenWebService::Gora::Plan 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
- :areaCode => '12,14',
12
- :playDate => '2016-04-24',
9
+ affiliateId: affiliate_id,
10
+ applicationId: application_id,
11
+ areaCode: '12,14',
12
+ playDate: '2016-04-24',
13
13
  }
14
14
  end
15
15
 
@@ -24,7 +24,7 @@ describe RakutenWebService::Gora::Plan do
24
24
  before do
25
25
  response = JSON.parse(fixture('gora/plan_search_with_area_code.json'))
26
26
  @expected_request = stub_request(:get, endpoint).
27
- with(:query => expected_query).to_return(:body => response.to_json)
27
+ with(query: expected_query).to_return(body: response.to_json)
28
28
  end
29
29
 
30
30
  specify 'endpoint should not be called' do
@@ -33,7 +33,7 @@ describe RakutenWebService::Gora::Plan do
33
33
 
34
34
  context 'just call the search method' do
35
35
  before do
36
- @plans = RakutenWebService::Gora::Plan.search(:areaCode => expected_query[:areaCode], :playDate => expected_query[:playDate])
36
+ @plans = RakutenWebService::Gora::Plan.search(areaCode: expected_query[:areaCode], playDate: expected_query[:playDate])
37
37
  end
38
38
 
39
39
  specify 'endpoint should not be called' do