aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2012-09-11 01:08:40 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2012-09-11 01:17:43 -0500
commitab7ae689e9727781ef39b01a836a746ac75352fc (patch)
treecd7a5df13571a7c227a8bd9e0be1bfb9043cdabc /actionpack/test
parent5d264f229c3798367e445d1ca02f3910ad9db547 (diff)
downloadrails-ab7ae689e9727781ef39b01a836a746ac75352fc.tar.gz
rails-ab7ae689e9727781ef39b01a836a746ac75352fc.tar.bz2
rails-ab7ae689e9727781ef39b01a836a746ac75352fc.zip
Add .rb template handler
This handler simply allows arbitrary Ruby code as a template
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/fixtures/ruby_template.rb3
-rw-r--r--actionpack/test/template/render_test.rb8
2 files changed, 11 insertions, 0 deletions
diff --git a/actionpack/test/fixtures/ruby_template.rb b/actionpack/test/fixtures/ruby_template.rb
new file mode 100644
index 0000000000..d99833a24d
--- /dev/null
+++ b/actionpack/test/fixtures/ruby_template.rb
@@ -0,0 +1,3 @@
+body = ""
+body << ["Hello", "from", "Ruby", "code"].join(" ")
+body
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb
index b26354e7cc..6279abaae5 100644
--- a/actionpack/test/template/render_test.rb
+++ b/actionpack/test/template/render_test.rb
@@ -97,6 +97,14 @@ module RenderTestCases
assert_equal %q;Here are some characters: !@#$%^&*()-="'}{`; + "\n", @view.render(:template => "plain_text_with_characters")
end
+ def test_render_rb_template_with_handlers
+ assert_equal "Hello from Ruby code", @view.render(:template => "ruby_template")
+ end
+
+ def test_render_rb_template_inline
+ assert_equal '4', @view.render(:inline => "(2**2).to_s", :type => :rb)
+ end
+
def test_render_file_with_localization_on_context_level
old_locale, @view.locale = @view.locale, :da
assert_equal "Hey verden", @view.render(:file => "test/hello_world")