jsonapi-rb / jsonapi-rspec

RSpec matchers for JSON:API spec
https://rubygems.org/gems/jsonapi-rspec
MIT License
123 stars 24 forks source link

Allow to use symbols in type matcher #26

Closed artofhuman closed 4 years ago

artofhuman commented 4 years ago

What is the current behavior?

expected hash should contain type as a string value

What is the new behavior?

allow use symbols and strings for type matcher

Example

if use jsonapi-serializer

serializer.new(entity, is_collection: false).serializable_hash

it returns hash where type is as a symbol

{:data=>
  {:id=>"1010",
   :type=>:timeoffs,
   :attributes=> ...
}

and it fails

expect(data).to have_type(:timeoffs)

To fix this workaround we can use

serializer.new(entity, is_collection: false).serializable_hash.as_json

but it requires one unnecessary action to transform all data in hash to strings

Checklist

Please make sure the following requirements are complete:

artofhuman commented 4 years ago

Ok I read this https://github.com/jsonapi-rb/jsonapi-rspec#on-matcher-arguments. So, i'm close this pr =)