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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 404100d143c51997a54c90beae1d40c2f30c38c62d83358c3b52147ca2528a9f
4
- data.tar.gz: 8c2abd999070e75c839193c513e7c443b65c36c7d31b2e9bd8c27a193a8aa0e1
3
+ metadata.gz: fa870b24a1c1b3fcd2f6fb783dce03bd6249ddfc4cf3de068213e63aa4ed966e
4
+ data.tar.gz: eba5c9887ceec4b26b538a4f20337976d4196b28e126052623f9572d1234a65d
5
5
  SHA512:
6
- metadata.gz: 2f69b0906838b7409d56adee6012bf83583b6f271394e8e3a4a4a171821df9b865551e58fea814f799afdf27084a01ca7d4be409a20610c528fc748dd61134b9
7
- data.tar.gz: 3a9c8bc87b5e83db4279bd7b286892a3b4869dd3fbe6bf44b47dd172a25fb2349cdad018b7d6d54e3d4119e9121e2601910bb34d91552c795927ac137eaa86fe
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
 
@@ -8,6 +8,7 @@ require 'jsonapi/rspec/relationships'
8
8
  require 'jsonapi/rspec/links'
9
9
  require 'jsonapi/rspec/meta'
10
10
  require 'jsonapi/rspec/jsonapi_object'
11
+ require 'jsonapi/rspec/errors'
11
12
 
12
13
  RSpec.configure do |c|
13
14
  c.add_setting :jsonapi_indifferent_hash, default: false
@@ -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.9
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-08-07 00:00:00.000000000 Z
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