{"id":22144965,"url":"https://github.com/jim/summon","last_synced_at":"2025-10-11T08:12:30.842Z","repository":{"id":645994,"uuid":"288173","full_name":"jim/summon","owner":"jim","description":"Provides a nice DSL for creating dummy data using Factory Girl factory definitions.","archived":false,"fork":false,"pushed_at":"2009-12-17T21:17:22.000Z","size":84,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-20T14:54:50.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/jim.png","metadata":{"files":{"readme":"README.rdoc","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":"2009-08-25T23:19:31.000Z","updated_at":"2013-12-22T14:41:19.000Z","dependencies_parsed_at":"2022-07-05T05:31:45.165Z","dependency_job_id":null,"html_url":"https://github.com/jim/summon","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jim/summon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fsummon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fsummon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fsummon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fsummon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jim","download_url":"https://codeload.github.com/jim/summon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jim%2Fsummon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278854216,"owners_count":26057418,"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-07T02:00:06.786Z","response_time":59,"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":[],"created_at":"2024-12-01T22:36:40.859Z","updated_at":"2025-10-11T08:12:30.803Z","avatar_url":"https://github.com/jim.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= summon\n\nProvides a nice DSL for creating dummy data using Factory Girl factory definitions.\n\n== Why\n\nNow that you've moved away from fixtures (well, you have, haven't you?) and started using factory_girl\nin your tests and specs, it would be nice to have a succinct way to generate dummy data for use in development.\n\nIn the past I've just used a bunch of extra factories for this, but it's a lot nicer to be able to build an\narbitrary number of objects, each with its own set of associations.\n\n== Example\n\nHere is an example Rakefile from a project I'm working on:\n\n  namespace :summon do\n    desc \"Builds a ton of dummy data\"\n    task :build =\u003e ['environment', 'db:reset'] do\n  \n      require 'spec/support/factories' # load factory definitions\n      require 'summon'\n      \n      published_date = lambda {\n        method = %w(ago since)[rand(2)]\n        rand(100).days.send(method)\n      }\n  \n      Summon(:label, 5)\n      Summon(:blog_topic, 10)\n  \n      Summon(:user, 20) do |user|\n        user.blogs(3..8,\n          :topic =\u003e BlogTopic.all,\n          :published_at =\u003e published_date\n        ) do |blog|\n          blog.comments 0..4\n        end\n      end\n  \n      Summon(:artist, 20) do |artist|\n        artist.events 4..6\n        artist.releases(0..5,\n         :label =\u003e Label.all\n        ) do |release|\n         release.tracks 8..12\n        end\n      end\n \n      puts \"Your minions are ready!\"\n \n    end\n  end\n\n== Installation\n\nI'd go for the gem.\n\n  sudo gem install jim-summon\n\n== Usage\n\n=== Specifying how many objects to build\n\nYou can use an integer or range when specifying how many objects to build:\n\n  Summon(:monkey, 3)         # build 3 monkeys\n  Summon(:monkey, 3..6)      # build between 3 and 6 monkeys\n\n=== Object attributes\n\nOther attributes to set on created objects (potentially overriding those defined by the factory)\nare passed in as a hash:\n\n  Summon(:monkey, 42, :dangerous =\u003e true)     # builds 42 dangerous monkeys\n    \nIf you pass a proc in as an attribute, it will be evaluated for each object and the resulting \nvalue used in its place.\n\nIf you pass an Array in as a value to an attribute, a value from the array will be selected at \nrandom. This might seem odd, but I've found it's much more common to want to set an attribute \nor association randomly from a set of options than set an attribute value to be an array. You \ncan always use a proc for this.\n\n== Associated objects\n\nThis is where the magic really happens. Use a block to define an object's associations, and \npotentially their attributes:\n\n  Summon(:car, 4) do |car|    # Build 4 cars, and in each...\n    car.passengers 3          # Build 3 passengers\n    car.driver                # Build one driver\n  end\n    \nRight now has_many and has_one associations are supported. has_many :through is not. Associations \ncan be nested as deep as you like:\n\n  Summon(:car, 4, :color =\u003e 'red') do |car|\n    car.passengers 3, :backseat_driver =\u003e true\n    car.driver do |driver|\n      driver.gloves 2             \n      driver.jacket do |jacket|\n        jacket.pockets 2, :cents =\u003e [0,5,10,25,50]\n      end\n    end\n  end\n\n== Note on Patches/Pull Requests\n \n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Commit, do not mess with rakefile, version, or history.\n  (if you want to have your own version, that is fine but\n   bump version in a commit by itself I can ignore when I pull)\n* Send me a pull request. Bonus points for topic branches.\n\n== Copyright\n\nCopyright (c) 2009 Jim Benton. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Fsummon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjim%2Fsummon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjim%2Fsummon/lists"}