spyke 1.7.1 → 1.7.2
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/README.md +8 -2
- data/lib/spyke/relation.rb +1 -1
- data/lib/spyke/scoping.rb +1 -1
- data/lib/spyke/version.rb +1 -1
- data/test/path_test.rb +6 -0
- data/test/relation_test.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bb23a4da9d9143ff6f62b5887a54b0244746be8
|
4
|
+
data.tar.gz: 926010cb42bae7510da165fa4c94cc69dbe96faa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a5ca662137935d28cd46ebe4fda3ca44a0158edde6c1d658f1a7195445a565626d393abb571d448564cee4910b75d9a477789b81b521591e56be0edac270267
|
7
|
+
data.tar.gz: 87ba21f060e68307b1aaf49386d180e2a511a5a5d8b4af9a68bd1f82ad9a585b4bb5760ea17e674d21a60e2e5260e4aaeaaa7702877cf14e0087b2d985fbee82
|
data/README.md
CHANGED
@@ -32,13 +32,19 @@ Add this line to your application's Gemfile:
|
|
32
32
|
gem 'spyke'
|
33
33
|
```
|
34
34
|
|
35
|
-
|
35
|
+
Spyke uses Faraday to handle requests and expects it to parse the response body into a hash in the following format:
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
{ data: { id: 1, name: 'Bob' }, metadata: {}, errors: [] }
|
39
39
|
```
|
40
40
|
|
41
|
-
|
41
|
+
So, for example for an API that returns JSON in the following format:
|
42
|
+
|
43
|
+
```json
|
44
|
+
{ "result": { "id": 1, "name": "Bob" }, "metadata": {}, "message": "" }
|
45
|
+
```
|
46
|
+
|
47
|
+
...the simplest possible configuration that could work is something like this:
|
42
48
|
|
43
49
|
```ruby
|
44
50
|
# config/initializers/spyke.rb
|
data/lib/spyke/relation.rb
CHANGED
@@ -6,7 +6,7 @@ module Spyke
|
|
6
6
|
|
7
7
|
attr_reader :klass, :params
|
8
8
|
attr_writer :params
|
9
|
-
delegate :to_ary, :[], :empty?, :last, :size, :metadata, to: :find_some
|
9
|
+
delegate :to_ary, :[], :any?, :empty?, :last, :size, :metadata, to: :find_some
|
10
10
|
|
11
11
|
def initialize(klass, options = {})
|
12
12
|
@klass, @options, @params = klass, options, {}
|
data/lib/spyke/scoping.rb
CHANGED
data/lib/spyke/version.rb
CHANGED
data/test/path_test.rb
CHANGED
@@ -25,5 +25,11 @@ module Spyke
|
|
25
25
|
Path.new('/users/:user_id/recipes/(:id)', id: 2).to_s
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
def test_optional_params_with_extension
|
30
|
+
skip 'wishlisted'
|
31
|
+
assert_equal '/1/profiles/2.json', Path.new('/1/profiles(/:id).json', id: 2).to_s
|
32
|
+
assert_equal '/1/profiles.json', Path.new('/1/profiles(/:id).json').to_s
|
33
|
+
end
|
28
34
|
end
|
29
35
|
end
|
data/test/relation_test.rb
CHANGED
@@ -12,6 +12,13 @@ module Spyke
|
|
12
12
|
assert_equal 'meta', recipes.metadata
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_any?
|
16
|
+
endpoint = stub_request(:get, 'http://sushi.com/recipes').to_return_json(result: [{ id: 1 }])
|
17
|
+
|
18
|
+
assert_equal true, Recipe.any?
|
19
|
+
assert_requested endpoint
|
20
|
+
end
|
21
|
+
|
15
22
|
def test_scope_independence
|
16
23
|
endpoint = stub_request(:get, 'http://sushi.com/recipes?query=chicken')
|
17
24
|
wrong_endpoint = stub_request(:get, 'http://sushi.com/recipes?query=chicken&page=1')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spyke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|