Skip to content

Convert have_id matcher argument to string. #31

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Don't convert actual id in have_id matcher
  • Loading branch information
wildfiler committed Jan 17, 2022
commit 27bbefdcfd97e3cd10681d9b4d65545090f518bb
2 changes: 1 addition & 1 deletion lib/jsonapi/rspec/id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module RSpec
module Id
::RSpec::Matchers.define :have_id do |expected|
match do |actual|
JSONAPI::RSpec.as_indifferent_hash(actual)['id'].to_s == expected.to_s
JSONAPI::RSpec.as_indifferent_hash(actual)['id'] == expected.to_s
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions spec/jsonapi/id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
expect('id' => '123').to have_id(123)
end

it 'succeeds when id is symbol' do
expect('id' => :foo).to have_id('foo')
end

it 'fails when id mismatches' do
expect('id' => 'foo').not_to have_id('bar')
end
Expand Down