{"id":21101163,"url":"https://github.com/brentgreeff/hash_factory","last_synced_at":"2025-12-29T15:41:31.403Z","repository":{"id":749229,"uuid":"401370","full_name":"brentgreeff/hash_factory","owner":"brentgreeff","description":"Light-weight Rails test factory","archived":false,"fork":false,"pushed_at":"2011-01-13T10:26:17.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-05T03:14:41.580Z","etag":null,"topics":["automated-testing","rails"],"latest_commit_sha":null,"homepage":"http://www.brentgreeff.com/rails-plugins/hash-factory","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/brentgreeff.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-12-06T04:11:39.000Z","updated_at":"2021-10-03T11:58:42.000Z","dependencies_parsed_at":"2022-08-16T10:45:28.032Z","dependency_job_id":null,"html_url":"https://github.com/brentgreeff/hash_factory","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/brentgreeff/hash_factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Fhash_factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Fhash_factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Fhash_factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Fhash_factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brentgreeff","download_url":"https://codeload.github.com/brentgreeff/hash_factory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Fhash_factory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278981539,"owners_count":26079644,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["automated-testing","rails"],"created_at":"2024-11-19T23:40:42.640Z","updated_at":"2025-10-08T17:17:11.661Z","avatar_url":"https://github.com/brentgreeff.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= HashFactory\n\n== Light-weight Rails test factory\n\n== Install\n\n      gem install hash_factory\n\nAdd this line to the top of test/test_helper.rb\n\n      require 'test_help' # this should already be here\n      HashFactory.setup\n\n\n== Lets start with the calling code\n\nI like to setup my test data in the test.\n\n* Along the lines of\n\n      test \"A User with a blank last name should be invalid\" do\n        @user = create_user :last_name =\u003e ''\n        assert @user.invalid?\n      end\n\n== A few things to notice:\n\nNo Factory calls, these methods are global to the test,\ndo I really need the namespace, will I ever need a SomethingElse.create_user\n\nI define the arguments relevant to the test explicitly.\nI dont need to look at the implementation to see if the user has a last_name.\n\nI assume the factory handles the rest and passes me a 'VALID' instance.\n\n== Test things in isolation\nA factory that returns an invalid instance will eventually cause a failure that ripples\nthrough your test code.\n\n\n== How to use it\n\n* create a factories directory:\n      \n      mkdir test/factories\n\nAdd a module to this folder and the methods\nautomatically become available in your tests.\n\n* Mine tend to look like this:\n      \n      module UserFactory\n        \n        def create_user(options={})\n          build :user, user_options(options)\n        end\n        \n        def user_options(options={})\n          {\n            :first_name =\u003e 'Jim',\n            :last_name =\u003e 'Bean',\n            :email =\u003e \"jim@example.com\",\n            :account =\u003e options[:account] || create_account\n          }.merge(options)\n        end\n      end\n\n\nAdd as many or as few files as you like.\n\nThe advantage of using this plugin is you can build your objects any way you like.\n\nDon't worry about protected attributes\nthe 'build' method handles it for you.\n\n=== Pluralization Issues\n\nBe sure to update your 'initializers/inflections.rb'\nIf you get an Constant missing error when loading a factory.\n\n\n=== Factory love in the console.\n\nCall\n\n      require 'hash_factory'\n      HashFactory.load_in(self)\n\nOr event better\n\ncopy the file:\n\n      config/initializers/factory_in_console.rb\n\nand it's always there waiting for you.\n\n\nCopyright (c) 2009 [Brent Greeff], released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrentgreeff%2Fhash_factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrentgreeff%2Fhash_factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrentgreeff%2Fhash_factory/lists"}