diff --git a/lib/jsonapi/rspec/relationships.rb b/lib/jsonapi/rspec/relationships.rb index a087132..30accc6 100644 --- a/lib/jsonapi/rspec/relationships.rb +++ b/lib/jsonapi/rspec/relationships.rb @@ -26,7 +26,7 @@ module Relationships match do |actual| return false unless actual.key?('relationships') - rels.all? { |rel| actual['relationships'].key?(rel) } + rels.all? { |rel| actual['relationships'].key?(rel.to_s) } end end end diff --git a/spec/jsonapi/relationships_spec.rb b/spec/jsonapi/relationships_spec.rb new file mode 100644 index 0000000..af25899 --- /dev/null +++ b/spec/jsonapi/relationships_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +RSpec.describe JSONAPI::RSpec do + let(:doc) do + JSON.parse('{"relationships": {"videos": [], "images": []}}') + end + context '#have_relationships' do + it 'succeeds when relationships are strings' do + expect(doc).to have_relationships('videos', 'images') + end + + it 'succeeds when relationships are symbols' do + expect(doc).to have_relationships(:videos, :images) + end + end +end