2009-03-03 19:42:20 -05:00
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
|
|
|
|
|
|
|
|
module AbstractController
|
|
|
|
module Testing
|
|
|
|
|
|
|
|
class ControllerWithHelpers < AbstractController::Base
|
2009-05-11 20:07:05 -04:00
|
|
|
include Renderer
|
|
|
|
include Helpers
|
2009-03-03 19:42:20 -05:00
|
|
|
|
2009-03-20 19:50:51 -04:00
|
|
|
def render(string)
|
|
|
|
super(:_template_name => string)
|
|
|
|
end
|
|
|
|
|
2009-03-03 19:42:20 -05:00
|
|
|
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
|
2009-06-08 19:14:38 -04:00
|
|
|
result = MyHelpers1.new.process(:index)
|
2009-05-11 13:22:07 -04:00
|
|
|
assert_equal "Hello World : Included", result.response_body
|
2009-03-03 19:42:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|