aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/abstract/helper_test.rb
blob: 5a363c9aa5af549ef33b1ed0a21756b7bb922575 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'abstract_unit'

module AbstractController
  module Testing
  
    class ControllerWithHelpers < AbstractController::Base
      include AbstractController::RenderingController
      include Helpers
      
      def render(string)
        super(:_template_name => string)
      end
      
      append_view_path File.expand_path(File.join(File.dirname(__FILE__), "views"))
    end
   
    module HelperyTest
      def included_method
        "Included"
      end
    end
   
    class MyHelpers1 < ControllerWithHelpers
      helper(HelperyTest) do
        def helpery_test
          "World"
        end
      end
      
      def index
        render "helper_test.erb"
      end
    end
    
    class TestHelpers < ActiveSupport::TestCase
      def test_helpers
        controller = MyHelpers1.new
        controller.process(:index)
        assert_equal "Hello World : Included", controller.response_body
      end
    end
    
  end
end