api-resource 0.5.4 → 0.5.5
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.
- checksums.yaml +4 -4
- data/lib/api-resource/resource.rb +1 -1
- data/lib/api-resource/version.rb +1 -1
- data/spec/resource_spec.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e0b3e5f0c0998f062cdd1657844dacc73edb38f
|
4
|
+
data.tar.gz: 6dcbfddbc124e80bd22f047eec0de88c118bcb36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a70f2851bf3dce62764ce8ada3bd055e909b028ea470275340d187c8431c8c5853737c6807209390d7178e2785a74e85374cdf99f691fbe0ef157453434331
|
7
|
+
data.tar.gz: e5b8bfb0c3d49809300f25b013d865b9cdb7818dd9ab3a33cc92aba17b2e410dbbd35d01fa351d5b7ebe279d01c57a90229c5134ccc70394346b868a5462d8ac
|
@@ -193,7 +193,7 @@ module ApiResource
|
|
193
193
|
def self.load_class(tableized_class)
|
194
194
|
tableized_class = name.to_s.tableize.split('/')[0...-1].push(tableized_class).join('/')
|
195
195
|
klass = tableized_class && tableized_class.to_s.singularize.classify.constantize rescue nil
|
196
|
-
klass if klass && klass <
|
196
|
+
klass if klass && klass < ApiResource::Resource
|
197
197
|
end
|
198
198
|
|
199
199
|
def self.client(verb, params, *paths)
|
data/lib/api-resource/version.rb
CHANGED
data/spec/resource_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
RSpec.describe
|
1
|
+
RSpec.describe ApiResource::Resource do
|
2
2
|
module BlogApi
|
3
|
-
class Resource <
|
3
|
+
class Resource < ApiResource::Resource
|
4
4
|
self.base_url = 'http://api.example.com'
|
5
5
|
end
|
6
6
|
|
@@ -195,7 +195,7 @@ RSpec.describe Logging::Resource do
|
|
195
195
|
|
196
196
|
context 'empty base_url' do
|
197
197
|
it 'throws on requests' do
|
198
|
-
class Foo <
|
198
|
+
class Foo < ApiResource::Resource;
|
199
199
|
end
|
200
200
|
expect(-> { Foo.all }).to raise_exception(StandardError)
|
201
201
|
end
|
@@ -271,7 +271,7 @@ RSpec.describe Logging::Resource do
|
|
271
271
|
it 'sets the returned errors' do
|
272
272
|
expected_value = { errors: { password_confrimation: ["can't be blank"], email: ["can't be blank", 'is invalid'] } }
|
273
273
|
stub = req(:post, '/sign_up', expected_value, 422, sign_up.attributes)
|
274
|
-
expect(proc { sign_up.submit! }).to raise_error(
|
274
|
+
expect(proc { sign_up.submit! }).to raise_error(ApiResource::ResourceError)
|
275
275
|
expect(sign_up.errors.messages).to match(expected_value[:errors])
|
276
276
|
expect(stub).to have_been_requested
|
277
277
|
end
|
@@ -279,7 +279,7 @@ RSpec.describe Logging::Resource do
|
|
279
279
|
it 'no request if not valid' do
|
280
280
|
sign_up.name = nil
|
281
281
|
stub = req(:post, '/sign_up', nil, 422)
|
282
|
-
expect(proc { sign_up.submit! }).to raise_error(
|
282
|
+
expect(proc { sign_up.submit! }).to raise_error(ApiResource::ResourceError)
|
283
283
|
expect(sign_up.errors[:name]).to be_truthy
|
284
284
|
expect(stub).to_not have_been_requested
|
285
285
|
end
|