Permalink
Browse files

Reinstate pending output buffer tests

  • Loading branch information...
1 parent cf3ccd7 commit d120f9de7e150ea6a5f21c834c1f1d0a9ea25d1a @jeremy jeremy committed May 28, 2009
Showing with 36 additions and 28 deletions.
  1. +36 −28 actionpack/test/template/output_buffer_test.rb
@@ -9,33 +9,41 @@ def index
tests TestController
- def test_flush_output_buffer
- pending
- # TODO: This tests needs to be rewritten due
- # The @response is not the same response object assigned
- # to the @controller.template
-
- # Start with the default body parts
- # ---
- # get :index
- # assert_equal ['foo'], @response.body_parts
- # assert_nil @controller.template.output_buffer
- #
- # # Nil output buffer is skipped
- # @controller.template.flush_output_buffer
- # assert_nil @controller.template.output_buffer
- # assert_equal ['foo'], @response.body_parts
- #
- # # Empty output buffer is skipped
- # @controller.template.output_buffer = ''
- # @controller.template.flush_output_buffer
- # assert_equal '', @controller.template.output_buffer
- # assert_equal ['foo'], @response.body_parts
- #
- # # Flushing appends the output buffer to the body parts
- # @controller.template.output_buffer = 'bar'
- # @controller.template.flush_output_buffer
- # assert_equal '', @controller.template.output_buffer
- # assert_equal ['foo', 'bar'], @response.body_parts
+ def setup
+ get :index
+ assert_equal ['foo'], body_parts
end
+
+ test 'output buffer is nil after rendering' do
+ assert_nil output_buffer
+ end
+
+ test 'flushing ignores nil output buffer' do
+ @controller.template.flush_output_buffer
+ assert_nil output_buffer
+ assert_equal ['foo'], body_parts
+ end
+
+ test 'flushing ignores empty output buffer' do
+ @controller.template.output_buffer = ''
+ @controller.template.flush_output_buffer
+ assert_equal '', output_buffer
+ assert_equal ['foo'], body_parts
+ end
+
+ test 'flushing appends the output buffer to the body parts' do
+ @controller.template.output_buffer = 'bar'
+ @controller.template.flush_output_buffer
+ assert_equal '', output_buffer
+ assert_equal ['foo', 'bar'], body_parts
+ end
+
+ protected
+ def output_buffer
+ @controller.template.output_buffer
+ end
+
+ def body_parts
+ @controller.template.response.body_parts
+ end
end

0 comments on commit d120f9d

Please sign in to comment.