spec/simply/html_builder/locals_spec.rb in smtlaissezfaire-simply-0.1.1 vs spec/simply/html_builder/locals_spec.rb in smtlaissezfaire-simply-0.2.1
- old
+ new
@@ -1,11 +1,11 @@
require File.dirname(__FILE__) + "/../../spec_helper"
module Simply
describe HTMLBuilder, "with locals" do
before(:each) do
- @builder = HTMLBuilder.new
+ @builder = HTMLBuilder.new(:indented => false)
end
it "should have access to a variables value" do
@builder.locals = { :foo => "bar" }
@builder.ul do
@@ -34,16 +34,27 @@
@builder.to_s.should == "<ul><li>1</li><li>2</li><li>3</li></ul>"
end
it "should take locals in the constructor" do
- builder = HTMLBuilder.new(:locals => { :foo => "bar", :bar => "baz" }) do
+ builder = HTMLBuilder.new(:locals => { :foo => "bar", :bar => "baz" }, :indented => false) do
ul do
li foo
li bar
end
end
builder.to_s.should == "<ul><li>bar</li><li>baz</li></ul>"
end
+
+ it "should be able to pass in several sets of locals at different times" do
+ builder = HTMLBuilder.new(:locals => {:foo => "1"}, :indented => false)
+ builder.locals = {:bar => "2"}
+ builder.ul do
+ li foo
+ li bar
+ end
+
+ builder.to_s.should == "<ul><li>1</li><li>2</li></ul>"
+ end
end
-end
\ No newline at end of file
+end