File tree Expand file tree Collapse file tree 7 files changed +14
-2
lines changed
Expand file tree Collapse file tree 7 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module RSpec
33 module Attributes
44 ::RSpec ::Matchers . define :have_attribute do |attr |
55 match do |actual |
6+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
67 ( actual [ 'attributes' ] || { } ) . key? ( attr . to_s ) &&
78 ( !@val_set || actual [ 'attributes' ] [ attr . to_s ] == @val )
89 end
@@ -15,6 +16,7 @@ module Attributes
1516
1617 ::RSpec ::Matchers . define :have_jsonapi_attributes do |*attrs |
1718 match do |actual |
19+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
1820 return false unless actual . key? ( 'attributes' )
1921
2022 counted = ( attrs . size == actual [ 'attributes' ] . size ) if @exactly
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ module JSONAPI
22 module RSpec
33 module Id
44 ::RSpec ::Matchers . define :have_id do |expected |
5- match { |actual | actual [ 'id' ] == expected }
5+ match do |actual |
6+ JSONAPI ::RSpec . as_indifferent_hash ( actual ) [ 'id' ] == expected
7+ end
68 end
79 end
810 end
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module RSpec
33 module JsonapiObject
44 ::RSpec ::Matchers . define :have_jsonapi_object do |val |
55 match do |actual |
6+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
67 actual . key? ( 'jsonapi' ) &&
78 ( !val || actual [ 'jsonapi' ] == val )
89 end
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module RSpec
33 module Links
44 ::RSpec ::Matchers . define :have_link do |link |
55 match do |actual |
6+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
67 actual . key? ( 'links' ) && actual [ 'links' ] . key? ( link . to_s ) &&
78 ( !@val_set || actual [ 'links' ] [ link . to_s ] == @val )
89 end
@@ -15,6 +16,7 @@ module Links
1516
1617 ::RSpec ::Matchers . define :have_links do |*links |
1718 match do |actual |
19+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
1820 return false unless actual . key? ( 'links' )
1921
2022 links . all? { |link | actual [ 'links' ] . key? ( link . to_s ) }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module RSpec
33 module Meta
44 ::RSpec ::Matchers . define :have_meta do |val |
55 match do |actual |
6+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
67 actual . key? ( 'meta' ) &&
78 ( !val || actual [ 'meta' ] == val )
89 end
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module RSpec
33 module Relationships
44 ::RSpec ::Matchers . define :have_relationship do |rel |
55 match do |actual |
6+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
67 return false unless ( actual [ 'relationships' ] || { } ) . key? ( rel . to_s )
78
89 !@data_set || actual [ 'relationships' ] [ rel . to_s ] [ 'data' ] == @data_val
@@ -25,6 +26,7 @@ module Relationships
2526
2627 ::RSpec ::Matchers . define :have_relationships do |*rels |
2728 match do |actual |
29+ actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
2830 return false unless actual . key? ( 'relationships' )
2931
3032 rels . all? { |rel | actual [ 'relationships' ] . key? ( rel ) }
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ module JSONAPI
22 module RSpec
33 module Type
44 ::RSpec ::Matchers . define :have_type do |expected |
5- match { |actual | actual [ 'type' ] == expected }
5+ match do |actual |
6+ JSONAPI ::RSpec . as_indifferent_hash ( actual ) [ 'type' ] == expected
7+ end
68 end
79 end
810 end
You can’t perform that action at this time.
0 commit comments