Froze rails gems
[depot.git] / vendor / rails / actionpack / test / controller / capture_test.rb
1 require 'abstract_unit'
2
3 class CaptureController < ActionController::Base
4 def self.controller_name; "test"; end
5 def self.controller_path; "test"; end
6
7 def content_for
8 render :layout => "talk_from_action"
9 end
10
11 def content_for_with_parameter
12 render :layout => "talk_from_action"
13 end
14
15 def content_for_concatenated
16 render :layout => "talk_from_action"
17 end
18
19 def non_erb_block_content_for
20 render :layout => "talk_from_action"
21 end
22
23 def rescue_action(e) raise end
24 end
25
26 class CaptureTest < Test::Unit::TestCase
27 def setup
28 @controller = CaptureController.new
29
30 # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
31 # a more accurate simulation of what happens in "real life".
32 @controller.logger = Logger.new(nil)
33
34 @request = ActionController::TestRequest.new
35 @response = ActionController::TestResponse.new
36
37 @request.host = "www.nextangle.com"
38 end
39
40 def test_simple_capture
41 get :capturing
42 assert_equal "Dreamy days", @response.body.strip
43 end
44
45 def test_content_for
46 get :content_for
47 assert_equal expected_content_for_output, @response.body
48 end
49
50 def test_should_concatentate_content_for
51 get :content_for_concatenated
52 assert_equal expected_content_for_output, @response.body
53 end
54
55 def test_should_set_content_for_with_parameter
56 get :content_for_with_parameter
57 assert_equal expected_content_for_output, @response.body
58 end
59
60 def test_non_erb_block_content_for
61 get :non_erb_block_content_for
62 assert_equal expected_content_for_output, @response.body
63 end
64
65 private
66 def expected_content_for_output
67 "<title>Putting stuff in the title!</title>\n\nGreat stuff!"
68 end
69 end