Skip to content
Browse files

disable builder tests when builder gem not installed

  • Loading branch information...
1 parent f71ac4f commit 0a26e8cef50d521ecb8834b5322eb23815c61a77 @rtomayko committed Dec 13, 2009
Showing with 34 additions and 30 deletions.
  1. +34 −30 test/tilt_buildertemplate_test.rb
View
64 test/tilt_buildertemplate_test.rb
@@ -1,40 +1,44 @@
require 'contest'
-require 'builder'
require 'tilt'
-class BuilderTemplateTest < Test::Unit::TestCase
- test "registered for '.builder' files" do
- assert_equal Tilt::BuilderTemplate, Tilt['test.builder']
- assert_equal Tilt::BuilderTemplate, Tilt['test.xml.builder']
- end
+begin
+ require 'builder'
+ class BuilderTemplateTest < Test::Unit::TestCase
+ test "registered for '.builder' files" do
+ assert_equal Tilt::BuilderTemplate, Tilt['test.builder']
+ assert_equal Tilt::BuilderTemplate, Tilt['test.xml.builder']
+ end
- test "compiling and evaluating the template on #render" do
- template = Tilt::BuilderTemplate.new { |t| "xml.em 'Hello World!'" }
- assert_equal "<em>Hello World!</em>\n", template.render
- end
+ test "compiling and evaluating the template on #render" do
+ template = Tilt::BuilderTemplate.new { |t| "xml.em 'Hello World!'" }
+ assert_equal "<em>Hello World!</em>\n", template.render
+ end
- test "passing locals" do
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + name + '!')" }
- assert_equal "<em>Hey Joe!</em>\n", template.render(Object.new, :name => 'Joe')
- end
+ test "passing locals" do
+ template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + name + '!')" }
+ assert_equal "<em>Hey Joe!</em>\n", template.render(Object.new, :name => 'Joe')
+ end
- test "evaluating in an object scope" do
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + @name + '!')" }
- scope = Object.new
- scope.instance_variable_set :@name, 'Joe'
- assert_equal "<em>Hey Joe!</em>\n", template.render(scope)
- end
+ test "evaluating in an object scope" do
+ template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + @name + '!')" }
+ scope = Object.new
+ scope.instance_variable_set :@name, 'Joe'
+ assert_equal "<em>Hey Joe!</em>\n", template.render(scope)
+ end
- test "passing a block for yield" do
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + yield + '!')" }
- assert_equal "<em>Hey Joe!</em>\n", template.render { 'Joe' }
- end
+ test "passing a block for yield" do
+ template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + yield + '!')" }
+ assert_equal "<em>Hey Joe!</em>\n", template.render { 'Joe' }
+ end
- test "block style templates" do
- template =
- Tilt::BuilderTemplate.new do |t|
- lambda { |xml| xml.em('Hey Joe!') }
- end
- assert_equal "<em>Hey Joe!</em>\n", template.render
+ test "block style templates" do
+ template =
+ Tilt::BuilderTemplate.new do |t|
+ lambda { |xml| xml.em('Hey Joe!') }
+ end
+ assert_equal "<em>Hey Joe!</em>\n", template.render
+ end
end
+rescue LoadError
+ warn "Tilt::BuilderTemplate (disabled)"
end

0 comments on commit 0a26e8c

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