{"id":16089617,"url":"https://github.com/leonelgalan/rspec-active_model_serializers","last_synced_at":"2025-03-18T06:30:54.441Z","repository":{"id":56892812,"uuid":"80567772","full_name":"leonelgalan/rspec-active_model_serializers","owner":"leonelgalan","description":"Simple testing of ActiveModelSerializers via a collection of matchers.","archived":false,"fork":false,"pushed_at":"2019-07-09T15:40:40.000Z","size":22,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T07:49:37.008Z","etag":null,"topics":["activemodelserializers","gem","json-schema","open-source","opensource","rspec","serialization","testing"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leonelgalan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-31T22:13:25.000Z","updated_at":"2019-07-09T15:40:42.000Z","dependencies_parsed_at":"2022-08-21T01:20:57.798Z","dependency_job_id":null,"html_url":"https://github.com/leonelgalan/rspec-active_model_serializers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Frspec-active_model_serializers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Frspec-active_model_serializers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Frspec-active_model_serializers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonelgalan%2Frspec-active_model_serializers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonelgalan","download_url":"https://codeload.github.com/leonelgalan/rspec-active_model_serializers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243907928,"owners_count":20367312,"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":["activemodelserializers","gem","json-schema","open-source","opensource","rspec","serialization","testing"],"created_at":"2024-10-09T14:04:56.105Z","updated_at":"2025-03-18T06:30:54.102Z","avatar_url":"https://github.com/leonelgalan.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rspec-active_model_serializers\n\n[![Build Status](https://travis-ci.org/leonelgalan/rspec-active_model_serializers.svg?branch=master)](https://travis-ci.org/leonelgalan/rspec-active_model_serializers)\n[![Code Climate](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers/badges/gpa.svg)](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers)\n[![Test Coverage](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers/badges/coverage.svg)](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers/coverage)\n[![Issue Count](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers/badges/issue_count.svg)](https://codeclimate.com/github/leonelgalan/rspec-active_model_serializers)\n[![Dependency Status](https://gemnasium.com/badges/github.com/leonelgalan/rspec-active_model_serializers.svg)](https://gemnasium.com/github.com/leonelgalan/rspec-active_model_serializers)\n[![Gem](https://img.shields.io/gem/v/rspec-active_model_serializers.svg)](https://rubygems.org/gems/rspec-active_model_serializers)\n\n## Installation\n\nAdd **rspec-active_model_serializers** the `:test` group in the _Gemfile_:\n\n```ruby\ngroup :test do\n  gem 'rspec-active_model_serializers'\nend\n```\n\n## Usage\n\n### `have_valid_schema`\n\nValidates the request or response against a [JSON\nSchema](http://json-schema.org/). You can customize which schema to use by\nchaining `.at_path(path_to_schema)`.\n\n```ruby\n# spec/rails_helper.rb\nActiveModelSerializers.config.schema_path = 'spec/support/schemas'\n```\n\n```ruby\n# spec/controller/posts_controller_spec.rb\nRspec.describe PostsController do\n  context 'GET /index' do\n    it 'responds with a valid schema' do\n      get :index\n      # Schema: spec/support/schemas/posts/index.json\n      expect(response).to have_valid_schema\n    end\n  end\n\n  context 'GET /show' do\n    it 'responds with a valid schema' do\n      get :show, id: 1\n      # Schema: spec/support/schemas/custom/show.json\n      expect(response).to have_valid_schema.at_path('custom/show.json')\n    end\n  end\nend\n```\n\n`expect(response_or_request).to have_valid_schema.at_path(path_to_schema)` can\nbe understood as being a translation of both\n`assert_response_schema(path_to_schema)` and\n`assert_request_schema(path_to_schema)`. See\n[ActiveModelSerializers::Test::Schema](https://github.com/rails-api/active_model_serializers/blob/v0.10.9/lib/active_model_serializers/test/schema.rb)\nand [RSpec::ActiveModelSerializers::Matchers::HaveValidSchema](lib/rspec/active_model_serializers/matchers/have_valid_schema.rb)\nfor additional documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Frspec-active_model_serializers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonelgalan%2Frspec-active_model_serializers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonelgalan%2Frspec-active_model_serializers/lists"}