File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ Available matchers:
3737* ` expect(document['data']).to have_jsonapi_attributes(:name, :email, :country).exactly `
3838* ` expect(document['data']).to have_attribute(:name).with_value('Lucas') `
3939* ` expect(document['data']).to have_relationships(:posts, :comments) `
40+ * ` expect(document['data']).to have_relationships(:posts, :comments, :likes).exactly `
4041* ` expect(document['data']).to have_relationship(:posts).with_data([{ 'id' => '1', 'type' => 'posts' }]) `
4142* ` expect(document['data']['relationships']['posts']).to have_links(:self, :related) `
4243* ` expect(document['data']).to have_link(:self).with_value('http://api.example.com/users/12') `
Original file line number Diff line number Diff line change @@ -29,7 +29,14 @@ module Relationships
2929 actual = JSONAPI ::RSpec . as_indifferent_hash ( actual )
3030 return false unless actual . key? ( 'relationships' )
3131
32- rels . map ( &:to_s ) . all? { |rel | actual [ 'relationships' ] . key? ( rel ) }
32+ counted = ( rels . size == actual [ 'relationships' ] . keys . size ) if @exactly
33+
34+ rels . map ( &:to_s ) . all? { |rel | actual [ 'relationships' ] . key? ( rel ) } \
35+ && ( counted == @exactly )
36+ end
37+
38+ chain :exactly do
39+ @exactly = true
3340 end
3441 end
3542 end
Original file line number Diff line number Diff line change 2323 it { expect ( doc ) . not_to have_relationship ( 'authors' ) }
2424 it { expect ( doc ) . to have_relationship ( 'user' ) }
2525
26+ it { expect ( doc ) . to have_relationships ( 'user' , 'comments' ) . exactly }
27+ it { expect ( doc ) . not_to have_relationships ( 'comments' ) . exactly }
28+
2629 it do
2730 expect ( doc ) . to have_relationship ( 'user' ) . with_data (
2831 { 'id' => '1' , 'type' => 'user' }
You can’t perform that action at this time.
0 commit comments