Skip to content
This repository
Browse code

Ensure factories prioritize static attributes in all cases

  • Loading branch information...
commit 854204dd12831a320f3226a875d9175ec68d1544 1 parent 4d4c01d
Thomas Walpole authored August 12, 2011 joshuaclayton committed August 20, 2011
29  spec/acceptance/attributes_ordered_spec.rb
@@ -19,14 +19,33 @@
19 19
           static 1
20 20
         end
21 21
       end
  22
+
  23
+      factory :without_parent, :class => ParentModel do
  24
+        evaluates_first   { static }
  25
+        evaluates_second  { evaluates_first }
  26
+        evaluates_third   { evaluates_second }
  27
+        static 1
  28
+      end
22 29
     end
23 30
   end
24 31
 
25  
-  subject { FactoryGirl.build(:child_model) }
  32
+  context "factory with a parent" do
  33
+    subject { FactoryGirl.build(:child_model) }
26 34
 
27  
-  it "assigns attributes in the order they're defined with preference to static attributes" do
28  
-    subject[:evaluates_first].should  == 1
29  
-    subject[:evaluates_second].should == 1
30  
-    subject[:evaluates_third].should  == 1
  35
+    it "assigns attributes in the order they're defined with preference to static attributes" do
  36
+      subject[:evaluates_first].should  == 1
  37
+      subject[:evaluates_second].should == 1
  38
+      subject[:evaluates_third].should  == 1
  39
+    end
  40
+  end
  41
+
  42
+  context "factory without a parent" do
  43
+    subject { FactoryGirl.build(:without_parent) }
  44
+
  45
+    it "assigns attributes in the order they're defined with preference to static attributes without a parent class" do
  46
+      subject[:evaluates_first].should  == 1
  47
+      subject[:evaluates_second].should == 1
  48
+      subject[:evaluates_third].should  == 1
  49
+    end
31 50
   end
32 51
 end

0 notes on commit 854204d

Please sign in to comment.
Something went wrong with that request. Please try again.