jsonapi-rspec 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/jsonapi/rspec.rb +1 -0
- data/lib/jsonapi/rspec/errors.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa870b24a1c1b3fcd2f6fb783dce03bd6249ddfc4cf3de068213e63aa4ed966e
|
4
|
+
data.tar.gz: eba5c9887ceec4b26b538a4f20337976d4196b28e126052623f9572d1234a65d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8ce2a95ddd8b843c24ef98856b771ff33c71f351bbc4f848b19eb425924a3814df254e8b8a288c64089caeb175fe54ce7acac263b42e45b5aae8b0919145f0
|
7
|
+
data.tar.gz: 3abf2abeb28e42e6294c36ce3fbd6e5a050ed79d990932614e44166b7f89d71e10bdf59e0b2eec415c3f57e66ebf500e3c75f49e40158660a727bedfc9b0d1fa
|
data/README.md
CHANGED
@@ -46,6 +46,7 @@ Available matchers:
|
|
46
46
|
* `expect(document).to have_meta('foo' => 'bar', 'fum' => 'baz').exactly`
|
47
47
|
* `expect(document).to have_jsonapi_object`
|
48
48
|
* `expect(document).to have_jsonapi_object('version' => '1.0')`
|
49
|
+
* `expect(document).to have_error('status' => '422')`
|
49
50
|
|
50
51
|
### On matcher arguments...
|
51
52
|
|
data/lib/jsonapi/rspec.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module JSONAPI
|
2
|
+
module RSpec
|
3
|
+
module Meta
|
4
|
+
::RSpec::Matchers.define :have_error do |error|
|
5
|
+
match do |actual|
|
6
|
+
actual = JSONAPI::RSpec.as_indifferent_hash(actual)
|
7
|
+
return false unless actual.key?('errors')
|
8
|
+
return false unless actual['errors'].is_a?(Array)
|
9
|
+
|
10
|
+
return true if actual['errors'].any? && error.nil?
|
11
|
+
|
12
|
+
error = JSONAPI::RSpec.as_indifferent_hash(error)
|
13
|
+
|
14
|
+
actual['errors'].any? { |actual_error| error <= actual_error }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.10
|
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-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- README.md
|
105
105
|
- lib/jsonapi/rspec.rb
|
106
106
|
- lib/jsonapi/rspec/attributes.rb
|
107
|
+
- lib/jsonapi/rspec/errors.rb
|
107
108
|
- lib/jsonapi/rspec/id.rb
|
108
109
|
- lib/jsonapi/rspec/jsonapi_object.rb
|
109
110
|
- lib/jsonapi/rspec/links.rb
|