3 # Doozer is a simple fixture generation library/plugin that handles all the annoying id management, and association building, allowing you to focus on crafting meaningful test fixtures.
5 # Here's a simple Doozer definition script:
7 # Doozer.define :page do
8 # field_order :title, :content, :author
9 # defaults :content=>'Content Here', :author=>'System', :created_on=>Time.now
12 # That tells Doozer that you are going to generate `page` fixtures. It then generates three macros for you to use: `page`, `page_id`, `pages`. With those macros, you can define your test data like this:
14 # page :root, "Home Page" do
15 # page :news, "News is always Fun!" do
16 # page :site_launch, "Site launched!", :created_on=>1.week.ago
17 # page :more_news, "More news", :created_on=>3.days.ago
21 # You can reference the same fixture multiple times, so you can create partial fixtures and complete them elsewhere.
23 # In our example so far, all of the pages will have the default content of "Content Here". Let's change that by calling the `page` macro again with just the content attribute. These will be added to the bottom of the definition file:
25 # page :root, :content=><<-EOC
26 # Welcome to this this site, please enjoy yourself!
29 # page :news, :content=>"I'm the parent page to all of the news!"
30 # page :site_launch, :content=>"Really, it was!"
32 # # So on, and so forth
34 # That's it for the definitions...
36 # Run `rake doozer:build` to generate the fixtures and you're done.
41 require 'active_support'
44 require 'doozer/definition'
45 require 'doozer/alt_definition'
46 require 'doozer/builder'
47 require 'doozer/version'