spec/musterb/template_handler_spec.rb in musterb-0.2.0 vs spec/musterb/template_handler_spec.rb in musterb-1.0.0
- old
+ new
@@ -5,11 +5,11 @@
def compile_template(template, options = {})
template = OpenStruct.new({:source => template, :locals => []}.merge(options))
"output_buffer = nil; " + Musterb::TemplateHandler::call(template)
end
- def evaluate(template, binding, options = {})
+ def evaluate(template, binding, options = {})
binding.eval compile_template(template, options)
end
it "is wired up correctly" do
foo = "hi"
@@ -23,11 +23,11 @@
it "escapes things by default" do
foo = "<br>"
evaluate("{{foo}}", binding, :locals => ["foo"]).should eq "<br>"
end
- it "does not escape things in triple staches" do
+ it "does not escape things in triple staches" do
foo = "<br>"
evaluate("{{{foo}}}", binding, :locals => ["foo"]).should eq "<br>"
end
it "can read from instance variables (likely on the controller)" do
@@ -43,6 +43,11 @@
it "favors locals over instance variables if passed into locals" do
@foo = "hello"
foo = "bye"
evaluate("{{foo}}", binding, :locals => ["foo"]).should eq "bye"
end
-end
\ No newline at end of file
+
+ it "can set the initial context to a hash" do
+ initial_context = 2
+ evaluate("{{to_s}}", binding, :locals => ["initial_context"]).should eq "2"
+ end
+end