Skip to content

Commit 2162b92

Browse files
committed
Convert have_id matcher argument to string.
1 parent 177e1d8 commit 2162b92

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/jsonapi/rspec/id.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module RSpec
33
module Id
44
::RSpec::Matchers.define :have_id do |expected|
55
match do |actual|
6-
JSONAPI::RSpec.as_indifferent_hash(actual)['id'] == expected
6+
JSONAPI::RSpec.as_indifferent_hash(actual)['id'].to_s == expected.to_s
77
end
88
end
99
end

spec/jsonapi/id_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
expect('id' => 'foo').to have_id('foo')
66
end
77

8+
it 'succeeds when expectation is integer' do
9+
expect('id' => '123').to have_id(123)
10+
end
11+
12+
it 'succeeds when id is symbol' do
13+
expect('id' => :foo).to have_id('foo')
14+
end
15+
816
it 'fails when id mismatches' do
917
expect('id' => 'foo').not_to have_id('bar')
1018
end

0 commit comments

Comments
 (0)