spyke 1.1.1 → 1.1.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/lib/spyke/relation.rb +5 -0
- data/lib/spyke/version.rb +1 -1
- data/test/associations_test.rb +11 -2
- data/test/relation_test.rb +8 -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: 4e5a33fdcfc000148eb3e3433b01207a31b007db
|
4
|
+
data.tar.gz: 443a50064d6ed572b4783037a09b6ae2ceaee48e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5219817c71603843bd3e0219f3a9b3fa32e23f96d88f1711de262cd766966ce874febc871a731628c10a36e5b107fb2b7d51a53d56b8af76231d9a1fe63f71b8
|
7
|
+
data.tar.gz: 5808dc0e274e18b6287ce0053ec351caba0c51b1292a395efb9b6ef449744af3886642d73d169dd3cb883fd5272da2ab063382bcd62bbb2be3fe25c7613c9ec5
|
data/lib/spyke/relation.rb
CHANGED
data/lib/spyke/version.rb
CHANGED
data/test/associations_test.rb
CHANGED
@@ -33,7 +33,7 @@ module Spyke
|
|
33
33
|
assert_equal %w{ Fish }, recipe.groups.map(&:name)
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def test_nested_embedded_associations
|
37
37
|
json = { result: { groups: [{ ingredients: [{ id: 1, name: 'Fish' }] }, { ingredients: [] }] } }
|
38
38
|
stub_request(:get, 'http://sushi.com/recipes/1').to_return_json(json)
|
39
39
|
|
@@ -42,7 +42,7 @@ module Spyke
|
|
42
42
|
assert_equal %w{ Fish }, recipe.ingredients.map(&:name)
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def test_singular_associations
|
46
46
|
stub_request(:get, 'http://sushi.com/recipes/1').to_return_json(result: { image: { url: 'bob.jpg' } })
|
47
47
|
|
48
48
|
recipe = Recipe.find(1)
|
@@ -59,6 +59,15 @@ module Spyke
|
|
59
59
|
assert_requested endpoint
|
60
60
|
end
|
61
61
|
|
62
|
+
def test_find_on_has_many_association
|
63
|
+
endpoint = stub_request(:get, 'http://sushi.com/recipes/1/groups/1').to_return_json(result: { id: 1 })
|
64
|
+
|
65
|
+
group = Recipe.new(id: 1).groups.find(1)
|
66
|
+
|
67
|
+
assert_requested endpoint
|
68
|
+
assert_equal 1, group.id
|
69
|
+
end
|
70
|
+
|
62
71
|
def test_unloaded_has_one_association
|
63
72
|
endpoint = stub_request(:get, 'http://sushi.com/recipes/1/image').to_return_json(result: { url: 'bob.jpg' })
|
64
73
|
|
data/test/relation_test.rb
CHANGED
@@ -12,6 +12,14 @@ module Spyke
|
|
12
12
|
assert_equal 'meta', recipes.metadata
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_scope_with_find
|
16
|
+
endpoint = stub_request(:get, 'http://sushi.com/recipes/1?status=published').to_return_json(result: { id: 1 })
|
17
|
+
|
18
|
+
Recipe.where(status: 'published').find(1)
|
19
|
+
|
20
|
+
assert_requested endpoint
|
21
|
+
end
|
22
|
+
|
15
23
|
def test_chainable_where
|
16
24
|
endpoint = stub_request(:get, 'http://sushi.com/recipes?status=published&per_page=3')
|
17
25
|
|
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.1.
|
4
|
+
version: 1.1.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: 2014-12-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|