jsonapi-rspec 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/jsonapi/rspec/attributes.rb +9 -2
- data/lib/jsonapi/rspec/relationships.rb +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b47e58f3f6448c75638d51bf9b1e71158cf0ba27e9ad2ef3de757eefef637cff
|
4
|
+
data.tar.gz: cb6760bd5fbcfd5302f8b53cca011588fedbc591674859a08c4272b820297ba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd3a469d0c1bdb3655f8d53b35a1dd4e65cb90d26ce7bd5dc8c3d9d8b391e352fa405fe76f9b49dc0943d263c6823abc6fa70904c3b7f4a420dc6ad53d62ea26
|
7
|
+
data.tar.gz: 8f2965c6f53ad2c2e92de9c550390eb964b07f3dfad58e3ded6e0527da5f61eb8aab126eeb758d34a53df36cf3e773a8b76ec40301c8022906950a2707bccfac
|
data/README.md
CHANGED
@@ -36,7 +36,8 @@ Available matchers:
|
|
36
36
|
|
37
37
|
* `expect(document['data']).to have_id('12')`
|
38
38
|
* `expect(document['data']).to have_type('users')`
|
39
|
-
* `expect(document['data']).to
|
39
|
+
* `expect(document['data']).to have_jsonapi_attributes(:name, :email)`
|
40
|
+
* `expect(document['data']).to have_jsonapi_attributes(:name, :email, :country).exactly`
|
40
41
|
* `expect(document['data']).to have_attribute(:name).with_value('Lucas')`
|
41
42
|
* `expect(document['data']).to have_relationships(:posts, :comments)`
|
42
43
|
* `expect(document['data']).to have_relationship(:posts).with_data([{ 'id' => '1', 'type' => 'posts' }])`
|
@@ -13,11 +13,18 @@ module JSONAPI
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
::RSpec::Matchers.define :
|
16
|
+
::RSpec::Matchers.define :have_jsonapi_attributes do |*attrs|
|
17
17
|
match do |actual|
|
18
18
|
return false unless actual.key?('attributes')
|
19
19
|
|
20
|
-
attrs.
|
20
|
+
counted = (attrs.size == actual['attributes'].size) if @exactly
|
21
|
+
|
22
|
+
(attrs.map(&:to_s) - actual['attributes'].keys).empty? &&
|
23
|
+
(counted == @exactly)
|
24
|
+
end
|
25
|
+
|
26
|
+
chain :exactly do
|
27
|
+
@exactly = true
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
@@ -17,7 +17,8 @@ module JSONAPI
|
|
17
17
|
if !(actual['relationships'] || {}).key?(rel.to_s)
|
18
18
|
"expected #{actual} to have relationship #{rel}"
|
19
19
|
else
|
20
|
-
"expected #{actual['relationships'][rel.to_s]}
|
20
|
+
"expected #{actual['relationships'][rel.to_s]} " \
|
21
|
+
"to have data #{@data_val}"
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Hosseini
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +53,7 @@ dependencies:
|
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
56
|
+
name: rubocop-performance
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|