public
Description: Who's your daddy? Kill Rails fixtures, Don't Repeat Yourself, reduce the complexity of your tests.
Homepage: http://tasks.ogtastic.com/projects/show/object-daddy
Clone URL: git://github.com/flogic/object_daddy.git
generate/generate! can now be thought of as analogs for create/create!
ymendel (author)
Wed Apr 16 12:56:12 -0700 2008
commit  e80c7b309481106b672252f55bd483620f4cf053
tree    f465296942605d699ac7e03c695c8dcfe11cf1d5
parent  eaf1e4b984369fb28d852ed00b56a0ff0ae5fed9
...
436
437
438
439
 
440
441
442
443
 
 
444
445
446
447
 
 
 
 
 
 
448
449
450
451
 
 
 
 
 
 
 
 
 
 
452
453
454
455
 
...
436
437
438
 
439
440
441
 
 
442
443
444
445
 
 
446
447
448
449
450
451
452
453
 
 
454
455
456
457
458
459
460
461
462
463
464
465
 
466
467
0
@@ -436,19 +436,31 @@ if File.exists?("#{File.dirname(__FILE__)}/../../../../config/environment.rb")
0
     end
0
     
0
     it "should return an unsaved record if spawning" do
0
-      Frobnitz.spawn.should be_new_record
0
+      Thing.spawn.should be_new_record
0
     end
0
     
0
-    it "should fail if trying to generate and save an invalid object" do
0
-      lambda { Frobnitz.generate!(:title => 'bob') }.should raise_error(ActiveRecord::RecordInvalid)
0
+    it "should return a saved record if generating" do
0
+      Thing.generate.should_not be_new_record
0
     end
0
     
0
-    it "should return a valid object if generate and save succeeds" do
0
-      Frobnitz.generate!(:title => '5', :name => 'blah').should be_valid
0
+    it 'should return a saved record if generating while raising exceptions' do
0
+      Thing.generate!.should_not be_new_record
0
+    end
0
+    
0
+    it "should not fail if trying to generate and save an invalid object" do
0
+      lambda { Frobnitz.generate(:title => 'bob') }.should_not raise_error(ActiveRecord::RecordInvalid)
0
     end
0
     
0
-    it "should return a saved object if generate and save succeeds" do
0
-      Frobnitz.generate!(:title => '5', :name => 'blah').should_not be_new_record
0
+    it "should return an invalid object if trying to generate and save an invalid object" do
0
+      Frobnitz.generate(:title => 'bob').should_not be_valid
0
+    end
0
+    
0
+    it "should fail if trying to generate and save an invalid object while raising acceptions" do
0
+      lambda { Frobnitz.generate!(:title => 'bob') }.should raise_error(ActiveRecord::RecordInvalid)
0
+    end
0
+    
0
+    it "should return a valid object if generate and save succeeds" do
0
+      Frobnitz.generate(:title => '5', :name => 'blah').should be_valid
0
     end
0
   end
0
-end
0
\ No newline at end of file
0
+end

Comments

chris Tue Apr 22 21:09:09 -0700 2008

Thank you!