{"id":15152719,"url":"https://github.com/siposdani87/mongoid-fixture-kit","last_synced_at":"2025-10-28T15:30:20.377Z","repository":{"id":65777606,"uuid":"599514124","full_name":"siposdani87/mongoid-fixture-kit","owner":"siposdani87","description":"This package is a Ruby gem that provides a way to load sample data into a MongoDB database for testing purposes. It provides a simple and convenient way to manage test data by defining fixtures in YAML files, which can be loaded into the database before running tests.","archived":false,"fork":false,"pushed_at":"2023-10-22T16:06:09.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T21:49:13.326Z","etag":null,"topics":["minitest","mongoid-plugin","rails7"],"latest_commit_sha":null,"homepage":"","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/siposdani87.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-09T09:52:26.000Z","updated_at":"2023-02-09T18:02:57.000Z","dependencies_parsed_at":"2024-09-22T00:01:47.372Z","dependency_job_id":"23b858f7-338a-4d88-afc8-aabf66b7167f","html_url":"https://github.com/siposdani87/mongoid-fixture-kit","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.045454545454545414","last_synced_commit":"fc5b0956f611c0126b6fafd983cf0659069a9e1b"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siposdani87%2Fmongoid-fixture-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siposdani87%2Fmongoid-fixture-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siposdani87%2Fmongoid-fixture-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siposdani87%2Fmongoid-fixture-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siposdani87","download_url":"https://codeload.github.com/siposdani87/mongoid-fixture-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238667876,"owners_count":19510495,"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":["minitest","mongoid-plugin","rails7"],"created_at":"2024-09-26T16:21:49.551Z","updated_at":"2025-10-28T15:30:15.000Z","avatar_url":"https://github.com/siposdani87.png","language":"Ruby","funding_links":["https://www.buymeacoffee.com/siposdani87"],"categories":[],"sub_categories":[],"readme":"# mongoid-fixture_kit\n\n[![Version](https://img.shields.io/gem/v/mongoid-fixture_kit.svg?style=square)](https://rubygems.org/gems/mongoid-fixture_kit)\n[![Download](https://img.shields.io/gem/dt/mongoid-fixture_kit.svg?style=square)](https://rubygems.org/gems/mongoid-fixture_kit)\n[![License](https://img.shields.io/github/license/siposdani87/mongoid-fixture-kit.svg?style=square)](./LICENSE)\n\n\u003ca href=\"https://www.buymeacoffee.com/siposdani87\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-green.png\" alt=\"Buy Me A Coffee\" width=\"150\" height=\"39\" /\u003e\u003c/a\u003e\n\nThis package is a Ruby gem that provides a way to load sample data into a MongoDB database for testing purposes. It provides a simple and convenient way to manage test data by defining fixtures in YAML files, which can be loaded into the database before running tests.\n\nThis library aims to provide fixtures for Mongoid the same way you have them with ActiveRecord.\n\n## Getting Started\n\n### Installing\n\n```ruby\ngem 'mongoid-fixture_kit'\n```\n\n### Usage\n\nIn your tests, add:\n\n```ruby\nclass ActiveSupport::TestCase\n  include Mongoid::FixtureKit::TestHelper\n  self.fixture_path = \"#{Rails.root}/test/fixtures\"\nend\n```\n\nThis is also done by `ActiveRecord`, but magically in the railties.\n\nThen when you want to access a fixture:\n\n```ruby\nclass UsersControllerTest \u003c ActionController::TestCase\n  setup do\n    @user = users(:user_1)\n  end\n  \n  test 'should show user' do\n    get :show, id: @user\n    assert_response :success\n  end\nend\n```\n\n### Features\n\n- Creation of a document from a YAML file.\n- ERB inside YAML files\n- `belongs_to` relations\n- Polymorphic `belongs_to`\n- `has_many` relations\n- `has_and_belongs_to_many` relations\n- `TestHelper` module to include in your tests\n\n### Notes\n\nDocuments are stored with a special attribute `__fixture_name` which is used to retrieve it and establish relations.\n\n`Mongoid::Document` has a `attr_accessor` defined for `__fixture_name`, so it doesn't pose any problem if you try to `dup` a document for example.\n\n### Changes compared to ActiveRecord\n\n- There is an option to load fixtures only once.\n- Fixture accessor methods are defined publicly.\n\nThese changes are here to let you create another class holding persistent data inside your tests.\n\n```ruby\nclass TestData\n  include Mongoid::FixtureKit::TestHelper\n\n  self.fixture_path = \"#{Rails.root}/test/fixtures_universes\"\n  self.load_fixtures_once = true\n\n  def TestData.instance\n    @instance ||= -\u003e(){\n      instance = new\n      instance.setup_fixtures\n      instance\n    }.call\n  end\n\n  private_class_method :new\nend\n\nclass ActiveSupport::TestCase\n  include Mongoid::FixtureKit::TestHelper\n  self.fixture_path = \"#{Rails.root}/test/fixtures\"\n\n  def data\n    TestData.instance\n  end\nend\n\n# somewhere else\ntest 'should validate complex data structure' do\n  assert_nothing_raised do\n    DataStructure.process(data.structures(:complex))\n  end\nend\n```\n\n## License\n\nThe original version of this library is [mongoid-fixture_set](https://github.com/Aethelflaed/mongoid-fixture_set) by Geoffroy Planquart in 2014\n\n## Bugs or Requests\n\nIf you encounter any problems feel free to open an [issue](https://github.com/siposdani87/mongoid-fixture-kit/issues/new?template=bug_report.md). If you feel the library is missing a feature, please raise a [ticket](https://github.com/siposdani87/mongoid-fixture-kit/issues/new?template=feature_request.md). Pull request are also welcome.\n\n[![DigitalOcean Referral Badge](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=b992bb656478\u0026utm_campaign=Referral_Invite\u0026utm_medium=Referral_Program\u0026utm_source=badge)\n\n## Developer\n\n[Dániel Sipos](https://siposdani87.com)\n\n## Sponsors\n\nThis project is generously supported by [TrophyMap](https://trophymap.org), [I18Nature](https://i18nature.com), and several other amazing organizations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiposdani87%2Fmongoid-fixture-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiposdani87%2Fmongoid-fixture-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiposdani87%2Fmongoid-fixture-kit/lists"}