{"id":17083619,"url":"https://github.com/smtlaissezfaire/fixturereplacement","last_synced_at":"2025-04-12T21:08:29.263Z","repository":{"id":388940,"uuid":"6468","full_name":"smtlaissezfaire/fixturereplacement","owner":"smtlaissezfaire","description":"FixtureReplacement rails plugin","archived":false,"fork":false,"pushed_at":"2023-04-12T06:26:30.000Z","size":529,"stargazers_count":17,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T21:08:08.188Z","etag":null,"topics":["data-generation","factory","factory-bot","factory-girl","factorybot","fixturereplacment","fixtures","ruby","rubygems","test","testing","testing-tools","thoughtbot"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smtlaissezfaire.png","metadata":{"files":{"readme":"README.rdoc","changelog":"CHANGELOG.rdoc","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2008-04-03T07:20:23.000Z","updated_at":"2023-08-19T14:44:34.000Z","dependencies_parsed_at":"2023-07-05T14:45:43.510Z","dependency_job_id":null,"html_url":"https://github.com/smtlaissezfaire/fixturereplacement","commit_stats":{"total_commits":465,"total_committers":5,"mean_commits":93.0,"dds":0.4666666666666667,"last_synced_commit":"986cb7104bb56d481c100349f8f762038be8dcea"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smtlaissezfaire%2Ffixturereplacement","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smtlaissezfaire%2Ffixturereplacement/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smtlaissezfaire%2Ffixturereplacement/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smtlaissezfaire%2Ffixturereplacement/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smtlaissezfaire","download_url":"https://codeload.github.com/smtlaissezfaire/fixturereplacement/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631677,"owners_count":21136562,"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":["data-generation","factory","factory-bot","factory-girl","factorybot","fixturereplacment","fixtures","ruby","rubygems","test","testing","testing-tools","thoughtbot"],"created_at":"2024-10-14T13:03:04.757Z","updated_at":"2025-04-12T21:08:29.222Z","avatar_url":"https://github.com/smtlaissezfaire.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= FixtureReplacement\n\n== What is FixtureReplacement?\n\nFixtureReplacement is a Rails gem that provides a simple way to\nquickly populate your test database with model objects without having to manage multiple,\nbrittle fixture files. You can easily set up complex object graphs (with models which\nreference other models) and add new objects on the fly.\n\n(If you've ever used FactoryGirl / FactoryBot, you're probably already quite familiar with\nfixture_replacement, as it proceeded FactoryGirl.  Also, FR is much more opinionated, and\nmuch less PC!)\n\nNot only can FixtureReplacement make your test data easier to maintain, it can also help\nto make your tests and specs much more readable and intention-revealing by allowing you\nto omit extraneous details and focus only on the attributes that are important for a\nparticular behaviour. It works well with both RSpec[http://rspec.rubyforge.org/] and\nTest::Unit[http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html].\n\n== What's new since 2.0:\n\n* default_* is gone in favor of new_*.\n* Cyclic dependencies are no longer an issue.  The \"overrides hash\" (the hash passed to new_* or create_*) can now be processed.\n\nSee CHANGELOG.rdoc + test suite for further changes.\n\n== Installation\n\nAdd it to your Gemfile:\n\n  group :development, :test do\n    gem \"fixture_replacement\", \"~\u003e 4.0\"\n  end\n\n=== Using it with RSpec\n\nAdd the following to your \u003ctt\u003espec/rails_helper.rb\u003c/tt\u003e file, in the configuration section:\n\n  RSpec.configure do |config|\n    config.include FixtureReplacement\n  end\n\n=== Using it with Test::Unit\n\nAdd the following to your \u003ctt\u003etest/test_helper.rb\u003c/tt\u003e file:\n\n  class Test::Unit::TestCase\n    include FixtureReplacement\n  end\n\n== How to use FixtureReplacement\n\n=== Defining default attributes\n\nAt the heart of FixtureReplacement is the \u003ctt\u003edb/example_data.rb\u003c/tt\u003e file where you\ndefine the default attributes for each of your test models. This example shows the default\nattributes for a user:\n\n  module FixtureReplacement\n\n    attributes_for :user do |u|\n      password = random_string\n\n      u.value                  = \"a value\",\n      u.other                  = \"other value\",\n      u.another                = random_string,     # random string 10 characters long\n      u.one_more               = random_string(15), # 15 characters long\n      u.password               = password,\n      u.password_confirmation  = password,\n      u.associated_object      = new_bar            # expects attributes_for :bar to be setup\n    end\n\n  end\n\nNote that:\n\n- A 'random_string' method is provided for attributes whose exact value isn't important; this means you can\n  create multiple, unique model instances\n- you can perform arbitrary set-up and execute any Ruby code prior to returning the hash\n  (as shown here where a \u003ctt\u003epassword\u003c/tt\u003e is generated and then used for both the \u003ctt\u003e:password\u003c/tt\u003e and\n  \u003ctt\u003e:password_confirmation\u003c/tt\u003e attributes)\n- a \u003ctt\u003enew_modelname\u003c/tt\u003e method is automatically provided that allows you to set up dependent\n  model objects (in this case an instance of the \u003ctt\u003eBar\u003c/tt\u003e model)\n\n=== Available methods\n\nBased on the above definition FixtureReplacement makes the following methods available:\n\n- \u003ctt\u003erandom_string\u003c/tt\u003e: generates a random string as shown above\n- \u003ctt\u003enew_user\u003c/tt\u003e: equivalent to \u003ctt\u003eUser.new\u003c/tt\u003e with the attributes for the user.\n- \u003ctt\u003ecreate_user\u003c/tt\u003e: equivalent to \u003ctt\u003eUser.create!\u003c/tt\u003e with the user's attributes.\n- \u003ctt\u003evalid_user_attributes\u003c/tt\u003e: returns a hash of the user's attributes including associations, specified in db/example_data.rb.\n\n=== Overriding attributes\n\nOverrides of specific attributes can be performed as follows:\n\n  new_user(:thing =\u003e \"overridden\")\n  create_user(:thing =\u003e \"overridden\")\n\nOverrides can also be used with associations:\n\n  scott = create_user(:username =\u003e \"scott\")\n  post = create_post(:user =\u003e scott)\n\n\n=== Validate your fixtures (thanks Fixjour)\n\nValidate your fixture definitions after including it in the spec helper or test helper:\n\n==== spec_helper.rb:\n\n  Spec::Runner.configuration do |config|\n    config.include FixtureReplacement\n  end\n\n  FixtureReplacement.validate!\n\n==== test_helper.rb\n\n  class Test::Unit::TestCase\n    include FixtureReplacement\n  end\n\n  FixtureReplacement.validate!\n\n=== Using FixtureReplacement within \u003ctt\u003escript/console\u003c/tt\u003e\n\n  $ ./script/console\n  Loading development environment\n  \u003e\u003e include FR\n  =\u003e Object\n  \u003e\u003e create_user\n  =\u003e #\u003cUser id: 1, crypted_password: \"521faec1c095...\" ...\u003e\n\n= Philosophy \u0026 Disadvantages\n\nSee philosophy_and_bugs.rdoc\n\n= Contributors, Contributions, \u0026 BUGS\n\nSee contributions.rdoc\n\n== License\n\nThis software is dual licensed under the MIT and the GPLv3 Licenses (it's your pick).\n\nCopyright 2007-2022 Scott Taylor / smtlaissezfaire[http://github.com/smtlaissezfaire] (scott@railsnewbie.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmtlaissezfaire%2Ffixturereplacement","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmtlaissezfaire%2Ffixturereplacement","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmtlaissezfaire%2Ffixturereplacement/lists"}