diff options
author | Xavier Noria <fxn@hashref.com> | 2010-03-16 20:33:38 +0100 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-03-16 13:10:54 -0700 |
commit | 986cac73e3c56b3dfa22fd1464f6913e38d32cc3 (patch) | |
tree | 26f9dc9c96bdcd8bbef28143e1e1754d07720885 | |
parent | 8c3e46c093023f9430c9772e81d58c9ee24de229 (diff) | |
download | rails-986cac73e3c56b3dfa22fd1464f6913e38d32cc3.tar.gz rails-986cac73e3c56b3dfa22fd1464f6913e38d32cc3.tar.bz2 rails-986cac73e3c56b3dfa22fd1464f6913e38d32cc3.zip |
adds tests for #capture
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
-rw-r--r-- | actionpack/test/template/capture_helper_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/test/template/capture_helper_test.rb b/actionpack/test/template/capture_helper_test.rb index e65f8b15ed..c1e83fc04d 100644 --- a/actionpack/test/template/capture_helper_test.rb +++ b/actionpack/test/template/capture_helper_test.rb @@ -7,6 +7,29 @@ class CaptureHelperTest < ActionView::TestCase @_content_for = Hash.new {|h,k| h[k] = "" } end + def test_capture_captures_the_temporary_output_buffer_in_its_block + assert_nil @av.output_buffer + string = @av.capture do + @av.output_buffer << 'foo' + @av.output_buffer << 'bar' + end + assert_nil @av.output_buffer + assert_equal 'foobar', string + assert_kind_of ActionView::NonConcattingString, string + end + + def test_capture_captures_the_value_returned_by_the_block_in_the_temporary_buffer_is_blank + string = @av.capture('foo', 'bar') do |a, b| + a + b + end + assert_equal 'foobar', string + assert_kind_of ActionView::NonConcattingString, string + end + + def test_capture_returns_nil_if_the_returned_value_is_not_a_string + assert_nil @av.capture { 1 } + end + def test_content_for assert ! content_for?(:title) content_for :title, 'title' |