reviewed 0.1.4 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. data/lib/faraday/api_key.rb +2 -4
  2. data/lib/reviewed/article.rb +1 -3
  3. data/lib/reviewed/base.rb +2 -19
  4. data/lib/reviewed/client.rb +7 -44
  5. data/lib/reviewed/product.rb +0 -2
  6. data/lib/reviewed/request.rb +35 -7
  7. data/lib/reviewed/version.rb +1 -1
  8. data/lib/reviewed.rb +2 -14
  9. data/reviewed.gemspec +0 -1
  10. data/spec/article_spec.rb +13 -12
  11. data/spec/base_spec.rb +2 -28
  12. data/spec/client_spec.rb +5 -72
  13. data/spec/collection_spec.rb +2 -1
  14. data/spec/faraday/api_key_spec.rb +21 -26
  15. data/spec/fixtures/vcr/article/find_page.yml +179 -0
  16. data/spec/fixtures/vcr/article/grill.yml +500 -0
  17. data/spec/fixtures/vcr/article/products.yml +500 -0
  18. data/spec/fixtures/vcr/collection/products.yml +525 -0
  19. data/spec/fixtures/vcr/product/attachments.yml +98 -0
  20. data/spec/fixtures/vcr/product/manufacturer_specs.yml +98 -0
  21. data/spec/fixtures/vcr/request/collection.yml +290 -0
  22. data/spec/fixtures/vcr/request/object.yml +7135 -0
  23. data/spec/fixtures/vcr/request/perform/no_params.yml +290 -0
  24. data/spec/fixtures/vcr/request/perform/params.yml +112 -0
  25. data/spec/fixtures/vcr/request/where/collection.yml +754 -0
  26. data/spec/product_spec.rb +4 -2
  27. data/spec/request_spec.rb +64 -9
  28. data/spec/reviewed_spec.rb +0 -9
  29. data/spec/spec_helper.rb +5 -6
  30. data/spec/website_spec.rb +2 -1
  31. metadata +25 -105
  32. data/lib/faraday/errors.rb +0 -14
  33. data/lib/reviewed/award.rb +0 -4
  34. data/spec/award_spec.rb +0 -4
  35. data/spec/faraday/errors_spec.rb +0 -73
  36. data/spec/fixtures/vcr/Reviewed_Article/associations/attachments/does_not_have_any_matching_attachments.yml +0 -601
  37. data/spec/fixtures/vcr/Reviewed_Article/associations/attachments/finds_attachments_by_tag.yml +0 -601
  38. data/spec/fixtures/vcr/Reviewed_Article/associations/attachments/has_many_attachments.yml +0 -601
  39. data/spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_all_attachments.yml +0 -601
  40. data/spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_attachments_of_the_correct_class.yml +0 -601
  41. data/spec/fixtures/vcr/Reviewed_Article/associations/pages/has_many_pages.yml +0 -601
  42. data/spec/fixtures/vcr/Reviewed_Article/associations/products/has_many_products.yml +0 -582
  43. data/spec/fixtures/vcr/Reviewed_Article/associations/products/returns_products_of_the_correct_class.yml +0 -601
  44. data/spec/fixtures/vcr/Reviewed_Article/find_page/finds_a_page_with_a_matching_slug.yml +0 -784
  45. data/spec/fixtures/vcr/Reviewed_Article/primary_product/returns_a_product_of_the_correct_class.yml +0 -1199
  46. data/spec/fixtures/vcr/Reviewed_Article/primary_product/returns_nil_if_does_not_respond_to_products.yml +0 -1199
  47. data/spec/fixtures/vcr/Reviewed_Article/primary_product/returns_the_primary_product.yml +0 -1199
  48. data/spec/fixtures/vcr/Reviewed_Client/_perform/request_params/not_set/has_nil_query_params.yml +0 -254
  49. data/spec/fixtures/vcr/Reviewed_Client/_perform/request_params/set/merges_quest_params.yml +0 -98
  50. data/spec/fixtures/vcr/Reviewed_Collection/collection_data/fetches_the_first_page_by_default.yml +0 -183
  51. data/spec/fixtures/vcr/Reviewed_Collection/collection_data/is_enumerable.yml +0 -183
  52. data/spec/fixtures/vcr/Reviewed_Collection/next_page/fetches_the_next_page_of_results.yml +0 -310
  53. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_if_the_page_number_is_out_of_bounds.yml +0 -183
  54. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_whether_this_is_the_first_or_last_page.yml +0 -183
  55. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_limit_value_max_per_page_.yml +0 -183
  56. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_number_of_entries_on_the_current_page.yml +0 -183
  57. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_offset.yml +0 -183
  58. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_item_count.yml +0 -183
  59. data/spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_number_of_pages.yml +0 -183
  60. data/spec/fixtures/vcr/Reviewed_Collection/previous_page/fetches_the_previous_page_of_results.yml +0 -490
  61. data/spec/fixtures/vcr/Reviewed_Collection/previous_page/returns_nil_if_there_is_no_previous_page.yml +0 -183
  62. data/spec/fixtures/vcr/Reviewed_Product/associations/attachments/does_not_have_any_matching_attachments.yml +0 -116
  63. data/spec/fixtures/vcr/Reviewed_Product/associations/attachments/finds_attachments_by_tag.yml +0 -116
  64. data/spec/fixtures/vcr/Reviewed_Product/associations/attachments/has_many_attachments.yml +0 -119
  65. data/spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_all_attachments.yml +0 -116
  66. data/spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_attachments_of_the_correct_class.yml +0 -119
  67. data/spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/has_many_manufacturer_specs.yml +0 -116
  68. data/spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/returns_attachments_of_the_correct_class.yml +0 -116
  69. data/spec/fixtures/vcr/Reviewed_Request/_where/filters_collections_using_other_supported_options.yml +0 -110
  70. data/spec/fixtures/vcr/Reviewed_Request/_where/returns_a_collection.yml +0 -254
  71. data/spec/fixtures/vcr/Reviewed_Request/_where/returns_an_empty_set_if_no_matching_data_was_found.yml +0 -86
  72. data/spec/fixtures/vcr/Reviewed_Request/_where/returns_the_appropriate_page_of_results.yml +0 -288
  73. data/spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_a_collection_object.yml +0 -254
  74. data/spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_objects_of_the_correct_class.yml +0 -254
  75. data/spec/fixtures/vcr/Reviewed_Request/object_from_response/returns_an_object_of_the_correct_class.yml +0 -601
data/spec/product_spec.rb CHANGED
@@ -8,7 +8,8 @@ describe Reviewed::Product do
8
8
 
9
9
  describe 'associations' do
10
10
 
11
- describe 'attachments', vcr: true do
11
+ describe 'attachments' do
12
+ use_vcr_cassette 'product/attachments'
12
13
 
13
14
  before(:each) do
14
15
  @product = client.products.find('minden-master-ii')
@@ -43,7 +44,8 @@ describe Reviewed::Product do
43
44
  end
44
45
  end
45
46
 
46
- describe 'manufacturer_specs', vcr: true do
47
+ describe 'manufacturer_specs' do
48
+ use_vcr_cassette 'product/manufacturer_specs'
47
49
 
48
50
  before(:each) do
49
51
  @product = client.products.find('minden-master-ii')
data/spec/request_spec.rb CHANGED
@@ -37,20 +37,48 @@ describe Reviewed::Request do
37
37
  end
38
38
  end
39
39
 
40
+ describe '#get' do
41
+
42
+ it 'delegates to perform' do
43
+ request.should_receive(:perform).with(:get, "path", kind_of(Hash))
44
+ request.get("path", {})
45
+ end
46
+ end
47
+
48
+ describe '#put' do
49
+
50
+ it 'delegates to request' do
51
+ request.should_receive(:perform).with(:put, "path", kind_of(Hash))
52
+ request.put("path", {})
53
+ end
54
+ end
55
+
56
+ describe '#post' do
57
+
58
+ it 'delegates to request' do
59
+ request.should_receive(:perform).with(:post, "path", kind_of(Hash))
60
+ request.post("path", {})
61
+ end
62
+ end
63
+
64
+ describe '#delete' do
65
+
66
+ it 'delegates to request' do
67
+ request.should_receive(:perform).with(:delete, "path", kind_of(Hash))
68
+ request.delete("path", {})
69
+ end
70
+ end
71
+
40
72
  describe '#find' do
41
73
 
42
74
  it 'delegates to object_from_response' do
43
75
  request.should_receive(:object_from_response).with(:get, "articles/123", {})
44
76
  request.find(123)
45
77
  end
46
-
47
- it 'cgi escapes id params' do
48
- request.should_receive(:object_from_response).with(:get, "articles/Smith+%26+Wesson+v%2Fs+Colt%3A+Which+Makes+you+Manlier%3F", {})
49
- request.find('Smith & Wesson v/s Colt: Which Makes you Manlier?')
50
- end
51
78
  end
52
79
 
53
- describe '#where', vcr: true do
80
+ describe '#where' do
81
+ use_vcr_cassette 'request/where/collection'
54
82
 
55
83
  it 'delegates to object_from_response' do
56
84
  request.should_receive(:collection_from_response).with(:get, "articles", {})
@@ -90,9 +118,10 @@ describe Reviewed::Request do
90
118
  end
91
119
  end
92
120
 
93
- describe 'object_from_response', vcr: true do
121
+ describe 'object_from_response' do
122
+ use_vcr_cassette "request/object"
94
123
 
95
- let(:article_id) { 'big-green-egg-medium-charcoal-grill-review' }
124
+ let(:article_id) { '509d166d60de7db97c05ce71' }
96
125
 
97
126
  it 'returns an object of the correct class' do
98
127
  response = request.object_from_response(:get, "articles/#{article_id}")
@@ -100,7 +129,8 @@ describe Reviewed::Request do
100
129
  end
101
130
  end
102
131
 
103
- describe 'collection_from_response', vcr: true do
132
+ describe 'collection_from_response' do
133
+ use_vcr_cassette "request/collection"
104
134
 
105
135
  it 'returns a collection object' do
106
136
  collection = request.collection_from_response(:get, "articles")
@@ -114,4 +144,29 @@ describe Reviewed::Request do
114
144
  end
115
145
  end
116
146
  end
147
+
148
+ describe '#perform' do
149
+
150
+ describe 'request_params' do
151
+
152
+ context 'set' do
153
+ use_vcr_cassette 'request/perform/params'
154
+
155
+ it 'merges quest params' do
156
+ request.client.request_params = { per_page: 1 }
157
+ collection = request.collection_from_response(:get, "articles")
158
+ collection.count.should eql(1)
159
+ end
160
+ end
161
+
162
+ context 'not set' do
163
+ use_vcr_cassette 'request/perform/no_params'
164
+
165
+ it 'has nil query params' do
166
+ collection = request.collection_from_response(:get, "articles")
167
+ collection.count.should eql(20)
168
+ end
169
+ end
170
+ end
171
+ end
117
172
  end
@@ -1,13 +1,4 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
3
  describe Reviewed do
4
-
5
- describe 'errors' do
6
-
7
- it 'should respond to url' do
8
- error = Reviewed::ResourceNotFound.new(url: 'url', msg: "msg")
9
- error.url.should eql('url')
10
- error.message.should eql('msg')
11
- end
12
- end
13
4
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
- require 'vcr'
5
4
  require 'reviewed'
5
+ require 'vcr'
6
6
 
7
7
  Dir['spec/support/*'].each { |f| require f }
8
8
 
@@ -11,16 +11,15 @@ RSpec.configure do |config|
11
11
  config.alias_example_to :fit, :focused => true
12
12
  config.alias_example_to :pit, :pending => true
13
13
  config.run_all_when_everything_filtered = true
14
+
15
+ config.extend VCR::RSpec::Macros
14
16
  end
15
17
 
16
18
  VCR.configure do |config|
17
19
  config.default_cassette_options = { record: :new_episodes }
18
20
  config.cassette_library_dir = 'spec/fixtures/vcr'
19
21
  config.hook_into :webmock
20
- config.configure_rspec_metadata!
21
22
  end
22
23
 
23
-
24
- TEST_URL = 'https://the-guide-staging.herokuapp.com/api/v1'
25
- TEST_KEY = ENV['REVIEWED_API_KEY']
26
-
24
+ TEST_URL = 'https://localhost:3000/api/v1'
25
+ TEST_KEY = '1234567890'
data/spec/website_spec.rb CHANGED
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Reviewed::Website do
4
4
 
5
- describe 'all', vcr: true do
5
+ describe 'all' do
6
+ use_vcr_cassette 'website/where_collection'
6
7
 
7
8
  it 'calls "where" with correct arguements' do
8
9
  Reviewed::Website.should_receive(:where).with({per_page: 'all'})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviewed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-22 00:00:00.000000000 Z
13
+ date: 2012-12-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -108,22 +108,6 @@ dependencies:
108
108
  - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rake
113
- requirement: !ruby/object:Gem::Requirement
114
- none: false
115
- requirements:
116
- - - ! '>='
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
- requirements:
124
- - - ! '>='
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
111
  - !ruby/object:Gem::Dependency
128
112
  name: rspec
129
113
  requirement: !ruby/object:Gem::Requirement
@@ -219,12 +203,10 @@ files:
219
203
  - README.md
220
204
  - Rakefile
221
205
  - lib/faraday/api_key.rb
222
- - lib/faraday/errors.rb
223
206
  - lib/reviewed.rb
224
207
  - lib/reviewed/article.rb
225
208
  - lib/reviewed/attachment.rb
226
209
  - lib/reviewed/author.rb
227
- - lib/reviewed/award.rb
228
210
  - lib/reviewed/base.rb
229
211
  - lib/reviewed/brand.rb
230
212
  - lib/reviewed/client.rb
@@ -239,54 +221,23 @@ files:
239
221
  - reviewed.gemspec
240
222
  - spec/article_spec.rb
241
223
  - spec/author_spec.rb
242
- - spec/award_spec.rb
243
224
  - spec/base_spec.rb
244
225
  - spec/brand_spec.rb
245
226
  - spec/client_spec.rb
246
227
  - spec/collection_spec.rb
247
228
  - spec/embeddable_spec.rb
248
229
  - spec/faraday/api_key_spec.rb
249
- - spec/faraday/errors_spec.rb
250
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/does_not_have_any_matching_attachments.yml
251
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/finds_attachments_by_tag.yml
252
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/has_many_attachments.yml
253
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_all_attachments.yml
254
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_attachments_of_the_correct_class.yml
255
- - spec/fixtures/vcr/Reviewed_Article/associations/pages/has_many_pages.yml
256
- - spec/fixtures/vcr/Reviewed_Article/associations/products/has_many_products.yml
257
- - spec/fixtures/vcr/Reviewed_Article/associations/products/returns_products_of_the_correct_class.yml
258
- - spec/fixtures/vcr/Reviewed_Article/find_page/finds_a_page_with_a_matching_slug.yml
259
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_a_product_of_the_correct_class.yml
260
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_nil_if_does_not_respond_to_products.yml
261
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_the_primary_product.yml
262
- - spec/fixtures/vcr/Reviewed_Client/_perform/request_params/not_set/has_nil_query_params.yml
263
- - spec/fixtures/vcr/Reviewed_Client/_perform/request_params/set/merges_quest_params.yml
264
- - spec/fixtures/vcr/Reviewed_Collection/collection_data/fetches_the_first_page_by_default.yml
265
- - spec/fixtures/vcr/Reviewed_Collection/collection_data/is_enumerable.yml
266
- - spec/fixtures/vcr/Reviewed_Collection/next_page/fetches_the_next_page_of_results.yml
267
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_if_the_page_number_is_out_of_bounds.yml
268
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_whether_this_is_the_first_or_last_page.yml
269
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_limit_value_max_per_page_.yml
270
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_number_of_entries_on_the_current_page.yml
271
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_offset.yml
272
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_item_count.yml
273
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_number_of_pages.yml
274
- - spec/fixtures/vcr/Reviewed_Collection/previous_page/fetches_the_previous_page_of_results.yml
275
- - spec/fixtures/vcr/Reviewed_Collection/previous_page/returns_nil_if_there_is_no_previous_page.yml
276
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/does_not_have_any_matching_attachments.yml
277
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/finds_attachments_by_tag.yml
278
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/has_many_attachments.yml
279
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_all_attachments.yml
280
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_attachments_of_the_correct_class.yml
281
- - spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/has_many_manufacturer_specs.yml
282
- - spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/returns_attachments_of_the_correct_class.yml
283
- - spec/fixtures/vcr/Reviewed_Request/_where/filters_collections_using_other_supported_options.yml
284
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_a_collection.yml
285
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_an_empty_set_if_no_matching_data_was_found.yml
286
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_the_appropriate_page_of_results.yml
287
- - spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_a_collection_object.yml
288
- - spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_objects_of_the_correct_class.yml
289
- - spec/fixtures/vcr/Reviewed_Request/object_from_response/returns_an_object_of_the_correct_class.yml
230
+ - spec/fixtures/vcr/article/find_page.yml
231
+ - spec/fixtures/vcr/article/grill.yml
232
+ - spec/fixtures/vcr/article/products.yml
233
+ - spec/fixtures/vcr/collection/products.yml
234
+ - spec/fixtures/vcr/product/attachments.yml
235
+ - spec/fixtures/vcr/product/manufacturer_specs.yml
236
+ - spec/fixtures/vcr/request/collection.yml
237
+ - spec/fixtures/vcr/request/object.yml
238
+ - spec/fixtures/vcr/request/perform/no_params.yml
239
+ - spec/fixtures/vcr/request/perform/params.yml
240
+ - spec/fixtures/vcr/request/where/collection.yml
290
241
  - spec/product_spec.rb
291
242
  - spec/request_spec.rb
292
243
  - spec/reviewed_spec.rb
@@ -313,61 +264,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
264
  version: '0'
314
265
  requirements: []
315
266
  rubyforge_project:
316
- rubygems_version: 1.8.25
267
+ rubygems_version: 1.8.24
317
268
  signing_key:
318
269
  specification_version: 3
319
270
  summary: A Ruby Gem for Accessing the Reviewed.com API
320
271
  test_files:
321
272
  - spec/article_spec.rb
322
273
  - spec/author_spec.rb
323
- - spec/award_spec.rb
324
274
  - spec/base_spec.rb
325
275
  - spec/brand_spec.rb
326
276
  - spec/client_spec.rb
327
277
  - spec/collection_spec.rb
328
278
  - spec/embeddable_spec.rb
329
279
  - spec/faraday/api_key_spec.rb
330
- - spec/faraday/errors_spec.rb
331
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/does_not_have_any_matching_attachments.yml
332
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/finds_attachments_by_tag.yml
333
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/has_many_attachments.yml
334
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_all_attachments.yml
335
- - spec/fixtures/vcr/Reviewed_Article/associations/attachments/returns_attachments_of_the_correct_class.yml
336
- - spec/fixtures/vcr/Reviewed_Article/associations/pages/has_many_pages.yml
337
- - spec/fixtures/vcr/Reviewed_Article/associations/products/has_many_products.yml
338
- - spec/fixtures/vcr/Reviewed_Article/associations/products/returns_products_of_the_correct_class.yml
339
- - spec/fixtures/vcr/Reviewed_Article/find_page/finds_a_page_with_a_matching_slug.yml
340
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_a_product_of_the_correct_class.yml
341
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_nil_if_does_not_respond_to_products.yml
342
- - spec/fixtures/vcr/Reviewed_Article/primary_product/returns_the_primary_product.yml
343
- - spec/fixtures/vcr/Reviewed_Client/_perform/request_params/not_set/has_nil_query_params.yml
344
- - spec/fixtures/vcr/Reviewed_Client/_perform/request_params/set/merges_quest_params.yml
345
- - spec/fixtures/vcr/Reviewed_Collection/collection_data/fetches_the_first_page_by_default.yml
346
- - spec/fixtures/vcr/Reviewed_Collection/collection_data/is_enumerable.yml
347
- - spec/fixtures/vcr/Reviewed_Collection/next_page/fetches_the_next_page_of_results.yml
348
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_if_the_page_number_is_out_of_bounds.yml
349
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/indicates_whether_this_is_the_first_or_last_page.yml
350
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_limit_value_max_per_page_.yml
351
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_number_of_entries_on_the_current_page.yml
352
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_offset.yml
353
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_item_count.yml
354
- - spec/fixtures/vcr/Reviewed_Collection/page_attributes_pagination_/returns_the_total_number_of_pages.yml
355
- - spec/fixtures/vcr/Reviewed_Collection/previous_page/fetches_the_previous_page_of_results.yml
356
- - spec/fixtures/vcr/Reviewed_Collection/previous_page/returns_nil_if_there_is_no_previous_page.yml
357
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/does_not_have_any_matching_attachments.yml
358
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/finds_attachments_by_tag.yml
359
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/has_many_attachments.yml
360
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_all_attachments.yml
361
- - spec/fixtures/vcr/Reviewed_Product/associations/attachments/returns_attachments_of_the_correct_class.yml
362
- - spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/has_many_manufacturer_specs.yml
363
- - spec/fixtures/vcr/Reviewed_Product/manufacturer_specs/returns_attachments_of_the_correct_class.yml
364
- - spec/fixtures/vcr/Reviewed_Request/_where/filters_collections_using_other_supported_options.yml
365
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_a_collection.yml
366
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_an_empty_set_if_no_matching_data_was_found.yml
367
- - spec/fixtures/vcr/Reviewed_Request/_where/returns_the_appropriate_page_of_results.yml
368
- - spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_a_collection_object.yml
369
- - spec/fixtures/vcr/Reviewed_Request/collection_from_response/returns_objects_of_the_correct_class.yml
370
- - spec/fixtures/vcr/Reviewed_Request/object_from_response/returns_an_object_of_the_correct_class.yml
280
+ - spec/fixtures/vcr/article/find_page.yml
281
+ - spec/fixtures/vcr/article/grill.yml
282
+ - spec/fixtures/vcr/article/products.yml
283
+ - spec/fixtures/vcr/collection/products.yml
284
+ - spec/fixtures/vcr/product/attachments.yml
285
+ - spec/fixtures/vcr/product/manufacturer_specs.yml
286
+ - spec/fixtures/vcr/request/collection.yml
287
+ - spec/fixtures/vcr/request/object.yml
288
+ - spec/fixtures/vcr/request/perform/no_params.yml
289
+ - spec/fixtures/vcr/request/perform/params.yml
290
+ - spec/fixtures/vcr/request/where/collection.yml
371
291
  - spec/product_spec.rb
372
292
  - spec/request_spec.rb
373
293
  - spec/reviewed_spec.rb
@@ -1,14 +0,0 @@
1
- module Faraday
2
- class Errors < Faraday::Middleware
3
-
4
- def call(env)
5
- @app.call(env).on_complete do
6
- if env[:response].status == 404
7
- raise Reviewed::ResourceNotFound.new(msg: 'Not Found', url: env[:url])
8
- end
9
- end
10
- end
11
- end
12
- end
13
-
14
- Faraday.register_middleware :response, errors: Faraday::Errors
@@ -1,4 +0,0 @@
1
- module Reviewed
2
- class Award < Base
3
- end
4
- end
data/spec/award_spec.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Reviewed::Award do
4
- end
@@ -1,73 +0,0 @@
1
- require 'spec_helper.rb'
2
-
3
- describe Faraday::Errors do
4
-
5
- describe 'error' do
6
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
7
- stub.get('/products/123') {[ 404, {}, { message: 'Record Not Found' } ]}
8
- end
9
-
10
- stubs2 = Faraday::Adapter::Test::Stubs.new do |stub|
11
- stub.get('/products/123') {[ 500, {}, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <style type="text/css"> html, body, iframe { margin: 0; padding: 0; height: 100%; } iframe { display: block; width: 100%; border: none; } </style> <title>Application Error</title></head> </head> <body> <iframe src="//s3.amazonaws.com/heroku_pages/error.html"> <p>Application Error</p> </iframe> </body> </html>' ]}
12
- end
13
-
14
- test = Faraday.new do |builder|
15
- builder.response :errors
16
- builder.response :json
17
- builder.adapter :test, stubs
18
- end
19
-
20
- test2 = Faraday.new do |builder|
21
- builder.response :errors
22
- builder.response :json
23
- builder.adapter :test, stubs2
24
- end
25
-
26
- it 'should raise a ResourceNotFound error' do
27
- expect {
28
- test.get('/products/123')
29
- }.to raise_error(Reviewed::ResourceNotFound) { |e|
30
- e.url.should be_an_instance_of(URI::HTTP)
31
- e.url.to_s.should eql('http:/products/123')
32
- e.message.should eql('Not Found')
33
- }
34
- end
35
-
36
- context 'faraday catch-all' do
37
-
38
- it 'raises an ApiError error' do
39
- client = Reviewed::Client.new
40
- client.stub!(:connection).and_return(test2)
41
- expect {
42
- client.send(:perform, :get, '/products/123')
43
- }.to raise_error(Reviewed::ApiError)
44
- end
45
-
46
- it 'passes other Reviewed errors through' do
47
- client = Reviewed::Client.new
48
- client.stub!(:connection).and_raise(Reviewed::ConfigurationError.new)
49
- expect {
50
- client.send(:perform, :get, '/products/123')
51
- }.to raise_error(Reviewed::ConfigurationError)
52
- end
53
- end
54
- end
55
-
56
- describe 'no error' do
57
- stubs = Faraday::Adapter::Test::Stubs.new do |stub|
58
- stub.get('/products/123') {[ 200, {}, { message: 'Record Not Found' } ]}
59
- end
60
-
61
- test = Faraday.new do |builder|
62
- builder.response :errors
63
- builder.response :json
64
- builder.adapter :test, stubs
65
- end
66
-
67
- it 'should not raise an error' do
68
- expect {
69
- test.get('/products/123')
70
- }.to_not raise_error
71
- end
72
- end
73
- end