{"id":13879337,"url":"https://github.com/jsonapi-rb/jsonapi-rspec","last_synced_at":"2025-04-04T21:10:30.367Z","repository":{"id":25239667,"uuid":"103529024","full_name":"jsonapi-rb/jsonapi-rspec","owner":"jsonapi-rb","description":"RSpec matchers for JSON:API spec","archived":false,"fork":false,"pushed_at":"2023-01-23T13:48:44.000Z","size":68,"stargazers_count":123,"open_issues_count":4,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T20:11:13.450Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/jsonapi-rspec","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/jsonapi-rb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-14T12:24:43.000Z","updated_at":"2023-07-24T06:42:15.000Z","dependencies_parsed_at":"2023-02-13T06:30:24.397Z","dependency_job_id":null,"html_url":"https://github.com/jsonapi-rb/jsonapi-rspec","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-rb%2Fjsonapi-rspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-rb%2Fjsonapi-rspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-rb%2Fjsonapi-rspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-rb%2Fjsonapi-rspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonapi-rb","download_url":"https://codeload.github.com/jsonapi-rb/jsonapi-rspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249532,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-06T08:02:17.580Z","updated_at":"2025-04-04T21:10:30.350Z","avatar_url":"https://github.com/jsonapi-rb.png","language":"Ruby","readme":"# jsonapi-rspec\n\nRSpec matchers for [JSON API](http://jsonapi.org).\n\n## Installation\n\nAdd the following to your application's Gemfile:\n```ruby\ngem 'jsonapi-rspec'\n```\nAnd then execute:\n```\n$ bundle\n```\n\nAdd to your `spec/spec_helpers.rb`:\n\n```ruby\n# spec/spec_helpers.rb\nrequire 'jsonapi/rspec'\n\nRSpec.configure do |config|\n  config.include JSONAPI::RSpec\n\n  # Support for documents with mixed string/symbol keys. Disabled by default.\n  config.jsonapi_indifferent_hash = true\nend\n```\n\n## Usage and documentation\n\nAvailable matchers:\n\n* `expect(document['data']).to have_id('12')`\n* `expect(document['data']).to have_type('users')`\n* `expect(document['data']).to have_jsonapi_attributes(:name, :email)`\n* `expect(document['data']).to have_jsonapi_attributes(:name, :email, :country).exactly`\n* `expect(document['data']).to have_attribute(:name).with_value('Lucas')`\n* `expect(document['data']).to have_relationships(:posts, :comments)`\n* `expect(document['data']).to have_relationships(:posts, :comments, :likes).exactly`\n* `expect(document['data']).to have_relationship(:posts).with_data([{ 'id' =\u003e '1', 'type' =\u003e 'posts' }])`\n* `expect(document['data']['relationships']['posts']).to have_links(:self, :related)`\n* `expect(document['data']).to have_link(:self).with_value('http://api.example.com/users/12')`\n* `expect(document).to have_meta`\n* `expect(document).to have_meta('foo' =\u003e 'bar')`\n* `expect(document).to have_meta('foo' =\u003e 'bar', 'fum' =\u003e 'baz').exactly`\n* `expect(document).to have_jsonapi_object`\n* `expect(document).to have_jsonapi_object('version' =\u003e '1.0')`\n* `expect(document).to have_error('status' =\u003e '422')`\n\n### On matcher arguments...\n\n**Note**: JSON:API spec requires JSON documents, thus attribute, relationship\nand link matcher arguments will always be converted into strings for\nconsistency!!!\n\nBasically, the tests bellow are absolutely equal:\n\n```ruby\nexpect(document['data']).to have_id(12)\nexpect(document['data']).to have_id('12')\n\nexpect(document['data']).to have_type(:users)\nexpect(document['data']).to have_type('users')\n\nexpect(document['data']).to have_jsonapi_attributes(:name, :email)\nexpect(document['data']).to have_jsonapi_attributes('name', 'email')\n```\n\nThe JSON:API spec also requires the `id` and `type` to be strings, so any other\nargument passed will also be converted into a string.\n\nIf the document you are trying to test has mixed string/symbol keys, just\nconfigure matchers to be indifferent in that regard, using the\n`jsonapi_indifferent_hash = true` configuration option.\n\n## Advanced examples\n\nChecking for an included resource:\n\n```ruby\nexpect(response_body['included'])\n  .to include(have_type('posts').and have_id('1'))\n```\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at\nhttps://github.com/jsonapi-rb/jsonapi-rspec\n\nThis project is intended to be a safe, welcoming space for collaboration, and\ncontributors are expected to adhere to the\n[Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\njsonapi-rspec is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonapi-rb%2Fjsonapi-rspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonapi-rb%2Fjsonapi-rspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonapi-rb%2Fjsonapi-rspec/lists"}