README.rdoc in watchmaker-0.1.2 vs README.rdoc in watchmaker-0.2.0

- old
+ new

@@ -10,76 +10,71 @@ * Share setup code between cucumber and test/unit by centralizing it. * Run this code in the console in development mode to seed your db with test data. == Using -=== Basics +=== Define profiles -Watchmaker creates persisted objects only. This is because these -objects are meant for integration tests where persistence is required. - -=== Learn profiles - ==== Implicit profiles Specify a dependency hash of profile name to objects. The watchmaker will either yield another watchmaker or a factory when resolving those dependencies. - Watchmaker.learn :lots_of_things => [:car, :garage, :boat] + Watchmaker.define :lots_of_things => [:car, :garage, :boat] ==== Lambda-based profiles When called, will call the lambda. - Watchmaker.learn :two_garages do + Watchmaker.define :two_garages do 2.times do Factory.create :garage end end ==== Factory-based profiles Create a garage using the garage factory. - Watchmaker.learn :garage, :factories => [:garage] do + Watchmaker.define :garage, :factories => [:garage] do # Some other post-factory creation setup here. end ==== Watchmaker-based profiles Create a garage using the garage factory. - Watchmaker.learn :garage, :factories => [:garage] + Watchmaker.define :garage, :factories => [:garage] Create a car using the car factory, and a garage using the garage watchmaker. - Watchmaker.learn :car, :factories => [:car], :watchmakers => [:garage] + Watchmaker.define :car, :factories => [:car], :watchmakers => [:garage] ==== Inject created objects into the lambda Inject the factory-created garage and car into the block. - Watchmaker.learn :car_in_garage, :factories => [:garage, :car] do |garage, car| + Watchmaker.define :car_in_garage, :factories => [:garage, :car] do |garage, car| garage.cars << car end -==== Grab your objects +=== Manufacture objects -Watchmaker returns the objects created. +Build in-memory objects using the two garages profile. - Watchmaker.construct(:garage).first.class # Garage + Watchmaker.build :two_garages -=== Construct objects +Build persisted objects using the two garages profile. -Build objects using the two garages profile. + Watchmaker.create :two_garages - Watchmaker.construct :two_garages +==== Get your objects back -Build objects using the garage profile. +Watchmaker returns the objects created. - Watchmaker.construct :garages + Watchmaker.create(:garage).first.class # Garage == Inspiration for the name William Paley's {Watchmaker Analogy and Argument}[http://en.wikipedia.org/wiki/Watchmaker_analogy#The_Watchmaker_argument].