Lots going on
[lyrix.git] / vendor / rails / actionpack / test / controller / capture_test.rb
blob42ec2568dae1b9bf9fa245d22177c3876f0e02f6
1 require File.dirname(__FILE__) + '/../abstract_unit'
3 class CaptureController < ActionController::Base
4   def self.controller_name; "test"; end
5   def self.controller_path; "test"; end
7   def content_for
8     render :layout => "talk_from_action"
9   end
11   def erb_content_for
12     render :layout => "talk_from_action"
13   end
15   def block_content_for
16     render :layout => "talk_from_action"
17   end
19   def non_erb_block_content_for
20     render :layout => "talk_from_action"
21   end
23   def rescue_action(e) raise end
24 end
26 CaptureController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
28 class CaptureTest < Test::Unit::TestCase
29   def setup
30     @controller = CaptureController.new
32     # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
33     # a more accurate simulation of what happens in "real life".
34     @controller.logger = Logger.new(nil)
36     @request    = ActionController::TestRequest.new
37     @response   = ActionController::TestResponse.new
39     @request.host = "www.nextangle.com"
40   end
42   def test_simple_capture
43     get :capturing
44     assert_equal "Dreamy days", @response.body.strip
45   end
47   def test_content_for
48     get :content_for
49     assert_equal expected_content_for_output, @response.body
50   end
52   def test_erb_content_for
53     get :content_for
54     assert_equal expected_content_for_output, @response.body
55   end
57   def test_block_content_for
58     get :block_content_for
59     assert_equal expected_content_for_output, @response.body
60   end
62   def test_non_erb_block_content_for
63     get :non_erb_block_content_for
64     assert_equal expected_content_for_output, @response.body
65   end
67   private
68     def expected_content_for_output
69       "<title>Putting stuff in the title!</title>\n\nGreat stuff!"
70     end
71 end