jsonapi-rspec 0.0.5 → 0.0.6
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 -5
- data/lib/jsonapi/rspec.rb +1 -0
- data/lib/jsonapi/rspec/meta.rb +9 -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: fa7320e501ff0cc08655a6e935589d300bedef20bc70add21f64d91d2e053a36
|
4
|
+
data.tar.gz: 1d31cafea53bb133cc8c62c274403bad9aaaa7dfcf4834679bd4cf2dbd246a8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727c5d55cfa976e4961dfe9798d1767bde29b364d7e4ff33dd52541a12c719c45f67bc021fd179432bd37ae60d26bc8477dce288eadb4b6365d0575570d3c6f0
|
7
|
+
data.tar.gz: bc74dd39b5b8186f7f6d945277f4fd8a091a20f9c33febf4ed52a788ac54778c6d176e20861261d5e7ef60a061cefdaf1fbefb4eaf63ff5163e661ee378ffde0
|
data/README.md
CHANGED
@@ -2,11 +2,6 @@
|
|
2
2
|
|
3
3
|
RSpec matchers for [JSON API](http://jsonapi.org).
|
4
4
|
|
5
|
-
## Resources
|
6
|
-
|
7
|
-
* Chat: [gitter](http://gitter.im/jsonapi-rb)
|
8
|
-
* Twitter: [@jsonapirb](http://twitter.com/jsonapirb)
|
9
|
-
|
10
5
|
## Installation
|
11
6
|
|
12
7
|
Add the following to your application's Gemfile:
|
@@ -30,6 +25,7 @@ RSpec.configure do |config|
|
|
30
25
|
# Support for documents with mixed string/symbol keys. Disabled by default.
|
31
26
|
config.jsonapi_indifferent_hash = true
|
32
27
|
end
|
28
|
+
```
|
33
29
|
|
34
30
|
## Usage and documentation
|
35
31
|
|
@@ -46,6 +42,7 @@ Available matchers:
|
|
46
42
|
* `expect(document['data']).to have_link(:self).with_value('http://api.example.com/users/12')`
|
47
43
|
* `expect(document).to have_meta`
|
48
44
|
* `expect(document).to have_meta('foo' => 'bar')`
|
45
|
+
* `expect(document).to have_meta('foo' => 'bar', 'fum' => 'baz').exactly`
|
49
46
|
* `expect(document).to have_jsonapi_object`
|
50
47
|
* `expect(document).to have_jsonapi_object('version' => '1.0')`
|
51
48
|
|
data/lib/jsonapi/rspec.rb
CHANGED
data/lib/jsonapi/rspec/meta.rb
CHANGED
@@ -4,9 +4,17 @@ module JSONAPI
|
|
4
4
|
::RSpec::Matchers.define :have_meta do |val|
|
5
5
|
match do |actual|
|
6
6
|
actual = JSONAPI::RSpec.as_indifferent_hash(actual)
|
7
|
+
return false unless actual.key?('meta')
|
8
|
+
return true unless val
|
9
|
+
|
7
10
|
val = JSONAPI::RSpec.as_indifferent_hash(val)
|
11
|
+
return false unless val <= actual['meta']
|
12
|
+
|
13
|
+
!@exactly || (@exactly && val.size == actual['meta'].size)
|
14
|
+
end
|
8
15
|
|
9
|
-
|
16
|
+
chain :exactly do
|
17
|
+
@exactly = true
|
10
18
|
end
|
11
19
|
end
|
12
20
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Hosseini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec-expectations
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|