diff --git a/lib/jsonapi/rspec/type.rb b/lib/jsonapi/rspec/type.rb index 75cff4e..57541ce 100644 --- a/lib/jsonapi/rspec/type.rb +++ b/lib/jsonapi/rspec/type.rb @@ -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 diff --git a/spec/jsonapi/type_spec.rb b/spec/jsonapi/type_spec.rb index 1b23233..be12962 100644 --- a/spec/jsonapi/type_spec.rb +++ b/spec/jsonapi/type_spec.rb @@ -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