Skip to content
Merged
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/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module RSpec
module Type
::RSpec::Matchers.define :have_type do |expected|
match do |actual|
JSONAPI::RSpec.as_indifferent_hash(actual)['type'] == expected.to_s
JSONAPI::RSpec.as_indifferent_hash(actual)['type'].to_s == expected.to_s
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/jsonapi/type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
expect('type' => 'foo').to have_type('foo')
end

it 'succeeds when expectation is symbol' do
expect('type' => 'foo').to have_type(:foo)
end

it 'succeeds when type is a symbol' do
expect('type' => :foo).to have_type('foo')
end

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