test/tilt_coffeescripttemplate_test.rb in tilt-1.2.2 vs test/tilt_coffeescripttemplate_test.rb in tilt-1.3

- old
+ new

@@ -18,11 +18,41 @@ template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } 3.times { assert_match "puts('Hello, World!');", template.render } end test "disabling coffee-script wrapper" do - template = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { |t| "puts 'Hello, World!'\n" } + str = "puts 'Hello, World!'\n" + + template = Tilt::CoffeeScriptTemplate.new(:bare => true) { str } assert_equal "puts('Hello, World!');", template.render + + template2 = Tilt::CoffeeScriptTemplate.new(:no_wrap => true) { str} + assert_equal "puts('Hello, World!');", template.render + end + + context "disabling coffee-script wrapper globally" do + setup do + @bare = Tilt::CoffeeScriptTemplate.default_bare + end + + teardown do + Tilt::CoffeeScriptTemplate.default_bare = @bare + end + + test "no options" do + template = Tilt::CoffeeScriptTemplate.new { |t| "puts 'Hello, World!'\n" } + assert_equal "puts('Hello, World!');", template.render + end + + test "overridden by :bare" do + template = Tilt::CoffeeScriptTemplate.new(:bare => false) { "puts 'Hello, World!'\n" } + assert_not_equal "puts('Hello, World!');", template.render + end + + test "overridden by :no_wrap" do + template = Tilt::CoffeeScriptTemplate.new(:no_wrap => false) { "puts 'Hello, World!'\n" } + assert_not_equal "puts('Hello, World!');", template.render + end end end rescue LoadError => boom warn "Tilt::CoffeeScriptTemplate (disabled)\n"