test/unit/test_boxes.rb in spontaneous-0.2.0.alpha2 vs test/unit/test_boxes.rb in spontaneous-0.2.0.alpha3

- old
+ new

@@ -336,33 +336,34 @@ child1.images << child3 child1.save @parent = Content[@parent.id] child1.reload; child2.reload; child3.reload @parent.images.contents.should == [child1] - @parent.images.pieces.should == [child1] + @parent.images.contents.should == [child1] @parent.words.contents.should == [child2] - @parent.words.pieces.should == [child2] - @parent.pieces.should == [child1, child2] - child1.images.pieces.should == [child3] - child1.pieces.should == [child3] + @parent.words.contents.should == [child2] + @parent.contents.should == [child1, child2] + child1.images.contents.should == [child3] + child1.contents.should == [child3] - @parent.images.pieces.first.box.should == @parent.images - @parent.words.pieces.first.box.should == @parent.words - @parent.pieces.first.box.should == @parent.images + @parent.images.contents.first.box.should == @parent.images + @parent.words.contents.first.box.should == @parent.words + @parent.contents.first.box.should == @parent.images end should "choose correct style" do styled = StyledContent.new child1 = BlankContent.new child2 = BlankContent.new child3 = BlankContent.new styled.one << child1 styled.two << child2 styled.save - styled = Content[styled.id] - styled.one.pieces.first.style.name.should == :blank2 - styled.two.pieces.first.style.name.should == :blank3 + styled = Content.first :id => styled.id + + styled.one.contents.first.style.name.should == :blank2 + styled.two.contents.first.style.name.should == :blank3 end should "be insertable at any position" do BlankContent.box :box3 BlankContent.box :box4 @@ -441,16 +442,16 @@ # should "raise an error when given an invalid type name" do # lambda { Parent.allow :WhatTheHellIsThis }.must_raise(NameError) # end should "allow all styles by default" do - Parent.allowed[2].styles.should == Allowed3.styles + Parent.allowed[2].styles(nil).should == Allowed3.styles end should "have a list of allowable styles" do - Parent.allowed[1].styles.length.should == 2 - Parent.allowed[1].styles.map { |s| s.name }.should == [:ringo, :george] + Parent.allowed[1].styles(nil).length.should == 2 + Parent.allowed[1].styles(nil).map { |s| s.name }.should == [:ringo, :george] end # TODO: decide on whether verifying style names is a good idea # should "raise an error if we try to use an unknown style" do # lambda { Parent.allow :Allowed3, :styles => [:merlin, :arthur] }.must_raise(Spontaneous::UnknownStyleException) @@ -458,11 +459,11 @@ should "use a configured style when adding a defined allowed type" do a = Allowable.new b = Allowed2.new a.parents << b - a.parents.pieces.first.style.prototype.should == Allowed2.styles[:ringo] + a.parents.contents.first.style.prototype.should == Allowed2.styles[:ringo] end should "know what the available styles are for an entry" do a = Allowable.new b = Allowed2.new @@ -560,9 +561,13 @@ @b.boxes.inner.render.should == "[a][b]" @b.boxes.outer.render.should == "[c][d][e]" @c.boxes.inner.render.should == "[a][b][f]" @c.boxes.outer.render.should == "[c][d][e]" + end + + should "return an empty array when asking for an unknown box group" do + @a.boxes.group(:nothing).should == [] end end end