{"id":24025227,"url":"https://github.com/kalashnikovisme/json_api_test_helpers","last_synced_at":"2026-06-11T06:31:50.895Z","repository":{"id":56879504,"uuid":"187293630","full_name":"kalashnikovisme/json_api_test_helpers","owner":"kalashnikovisme","description":"Helpers for testing JSON API","archived":false,"fork":false,"pushed_at":"2022-01-14T17:12:30.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-29T00:51:51.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kalashnikovisme.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-17T23:40:21.000Z","updated_at":"2022-01-09T11:04:56.000Z","dependencies_parsed_at":"2022-08-20T23:10:49.294Z","dependency_job_id":null,"html_url":"https://github.com/kalashnikovisme/json_api_test_helpers","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/kalashnikovisme/json_api_test_helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalashnikovisme%2Fjson_api_test_helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalashnikovisme%2Fjson_api_test_helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalashnikovisme%2Fjson_api_test_helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalashnikovisme%2Fjson_api_test_helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kalashnikovisme","download_url":"https://codeload.github.com/kalashnikovisme/json_api_test_helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalashnikovisme%2Fjson_api_test_helpers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34186385,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-08T15:48:06.500Z","updated_at":"2026-06-11T06:31:50.867Z","avatar_url":"https://github.com/kalashnikovisme.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonApiTestHelpers\n\nCollection of helper methods to easy testing of JSON API https://jsonapi.org/ responses\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'json_api_test_helpers'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install json_api_test_helpers\n\n## Usage\n\nMethods:\n\n| Methods       | Params  | Description                                                             |\n|---------------|---------|-------------------------------------------------------------------------|\n| json_response |         | Returns parsed `response.body` as Hash with indifferent access or Array |\n| json_api_record | `record`, `attributes`, `relationships: nil`, `additional: nil`| Returns Hash in JSON API format with serialized object |\n| json_api_collection | `collection`, `attributes = nil`, `relationships: nil` | Returns Hash in JSON API format with serialized array |\n| json_api_relationships | `record`, `relationships` | Returns Hash of the record's relationships. When `relationships` argument is Array, all releations have name same as model class names. When it's Hash { relationship_name =\u003e class_name } | \n| fix_value_for_json | `value` | Fix values which are usually used in Rails apps. `DateTime`, `ActiveSupport::TimeWithZone` to `iso8601`; `CarrierWave::Uploader::Serialization` to `serializable_hash`; everything else to Hash with replaced underscores `_` to minus `-` in attribute names |\n| fix_comparing_types | `value` | Fix type value to easy compare. `DateTime`, `ActiveSupport::TimeWithZone` to `datetime` with UTC; `ActiveRecord::Point` to string `\"#{value.x}, #{value.y}\"`. |\n| attributes_for_nested | `attributes`, `**associations` | Merge `attributes` with associations with JSON API format |\n| json_api_params | `attributes` | Put params to `{ data: { attributes: your_params }}` object |\n\n## Examples\n\n```ruby\nexpect(json_response).to include_json(json_api_record(User.first, [ :email, :another_attribute ]))\n\nexpect(json_response).to include_json(json_api_collection(User.all))\n\nexpect(json_response).to include_json(json_api_relationships(user, posts: :user_posts))\n\npost 'some_post', params: json_api_params({ attribute1: :value1, attribute2: :value2 })\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/json_api_test_helpers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the JsonApiTestHelpers project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/json_api_test_helpers/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalashnikovisme%2Fjson_api_test_helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalashnikovisme%2Fjson_api_test_helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalashnikovisme%2Fjson_api_test_helpers/lists"}