Skip to content

Make #have_relationships accept symbols #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jsonapi/rspec/relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/jsonapi/relationships_spec.rb
Original file line number Diff line number Diff line change
@@ -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