{"id":17020556,"url":"https://github.com/monade/rspec_create_model","last_synced_at":"2025-11-11T19:29:28.606Z","repository":{"id":37574429,"uuid":"502045667","full_name":"monade/rspec_create_model","owner":"monade","description":"rspec_create_model, a rspec matcher to verify that a created model respects what you expect","archived":false,"fork":false,"pushed_at":"2022-07-29T15:08:30.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-12T10:12:55.626Z","etag":null,"topics":["gem","rails","rspec-matchers","ruby"],"latest_commit_sha":null,"homepage":"https://monade.io/en/home-en/","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/monade.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":"2022-06-10T13:02:25.000Z","updated_at":"2023-02-17T20:58:01.000Z","dependencies_parsed_at":"2022-08-29T06:40:14.877Z","dependency_job_id":null,"html_url":"https://github.com/monade/rspec_create_model","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/monade%2Frspec_create_model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Frspec_create_model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Frspec_create_model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monade%2Frspec_create_model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monade","download_url":"https://codeload.github.com/monade/rspec_create_model/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550633,"owners_count":21122934,"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":["gem","rails","rspec-matchers","ruby"],"created_at":"2024-10-14T07:05:24.723Z","updated_at":"2025-11-11T19:29:23.586Z","avatar_url":"https://github.com/monade.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Tests](https://github.com/monade/rspec_create_model/actions/workflows/test.yml/badge.svg)\n[![Gem Version](https://badge.fury.io/rb/rspec_create_model.svg)](https://badge.fury.io/rb/rspec_create_model)\n\n# rspec_create_model\n\nA rspec matcher for Rail's ActiveRecord, to check the type of models created from actions.\n\n## Installation\n\nAdd the gem to your Gemfile\n\n```ruby\n  gem 'rspec_create_model'\n```\n\n## Example usage\n\nGiven the following records:\n\n```ruby\nclass Author \u003c ActiveRecord::Base\n  attribute :name, type: :String\n  has_many :articles, dependent: :destroy\n\n  after_create :create_empty_book\n\n  def create_empty_book\n    Book.create!(author_id: id, title: \"First Empty Book\")\n  end\nend\n\nclass Book \u003c ActiveRecord::Base\n  belongs_to :author, optional: false\n  attribute :title, type: :String\nend\n```\n\nYou can match created records like this:\n\n```ruby\nexpect { Author.create!(name: \"Some author name\") }.to create_model(Author)\n\nexpect { Author.create!(name: \"Some author name\") }\n  .to create_model(Author)\n  .and create_model(Book)\n```\n\nWhen the matcher is called, 2 instace variable get set: **@created_record** and **@created_records**\n\nthese variables includes the newly created records. You can also use them if you want, like this:\n\n```ruby\nexpect { Author.create!(name: \"Some author name\") }.to create_model(Author)\n\nexpect(@created_record).to be_a(Author)\nexpect(@created_records).to all(be_a(Author))\n```\n\nincluding the created records, you also could write tests on their content.\n\nRemember to checkout the Gem's specs to see how to use it!\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\nAbout Monade\n----------------\n\n![monade](https://monade.io/wp-content/uploads/2021/06/monadelogo.png)\n\nrspec_create_model is maintained by [mònade srl](https://monade.io/en/home-en/).\n\nWe \u003c3 open source software. [Contact us](https://monade.io/en/contact-us/) for your next project!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Frspec_create_model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonade%2Frspec_create_model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonade%2Frspec_create_model/lists"}