Skip to content
Browse files

adds tests for #capture

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 8c3e46c commit 986cac73e3c56b3dfa22fd1464f6913e38d32cc3 @fxn fxn committed with jeremy Mar 16, 2010
Showing with 23 additions and 0 deletions.
  1. +23 −0 actionpack/test/template/capture_helper_test.rb
View
23 actionpack/test/template/capture_helper_test.rb
@@ -7,6 +7,29 @@ def setup
@_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'

0 comments on commit 986cac7

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