Skip to content

Allow to use symbols in type matcher #26

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

Closed
wants to merge 1 commit into from

Conversation

artofhuman
Copy link

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:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes /
    features)
  • All automated checks pass (CI/CD)

@artofhuman
Copy link
Author

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

@artofhuman artofhuman closed this Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant