class HelperTest
Public Instance Methods
call_controller(klass, action)
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 139 def call_controller(klass, action) klass.action(action).call(ActionController::TestRequest::DEFAULT_ENV.dup) end
setup()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 109 def setup # Increment symbol counter. @symbol = (@@counter ||= "A0").succ.dup # Generate new controller class. controller_class_name = "Helper#{@symbol}Controller" eval("class #{controller_class_name} < TestController; end") @controller_class = self.class.const_get(controller_class_name) # Set default test helper. self.test_helper = LocalAbcHelper end
test_all_helpers()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 169 def test_all_helpers methods = AllHelpersController._helpers.instance_methods # abc_helper.rb assert_includes methods, :bare_a # fun/games_helper.rb assert_includes methods, :stratego # fun/pdf_helper.rb assert_includes methods, :foobar end
test_all_helpers_with_alternate_helper_dir()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 182 def test_all_helpers_with_alternate_helper_dir @controller_class.helpers_path = File.expand_path("../fixtures/alternate_helpers", __dir__) # Reload helpers @controller_class._helpers = Module.new @controller_class.helper :all # helpers/abc_helper.rb should not be included assert_not_includes master_helper_methods, :bare_a # alternate_helpers/foo_helper.rb assert_includes master_helper_methods, :baz end
test_base_helper_methods_after_clear_helpers()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 157 def test_base_helper_methods_after_clear_helpers assert_nothing_raised do call_controller(JustMeController, "flash") end end
test_default_helpers_only()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 152 def test_default_helpers_only assert_equal [JustMeHelper], JustMeController._helpers.ancestors.reject(&:anonymous?) assert_equal [MeTooHelper, JustMeHelper], MeTooController._helpers.ancestors.reject(&:anonymous?) end
test_helper()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 122 def test_helper assert_equal expected_helper_methods, missing_methods assert_nothing_raised { @controller_class.helper TestHelper } assert_equal [], missing_methods end
test_helper_attr()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 133 def test_helper_attr assert_nothing_raised { @controller_class.helper_attr :delegate_attr } assert_includes master_helper_methods, :delegate_attr assert_includes master_helper_methods, :delegate_attr= end
test_helper_for_acronym_controller()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 148 def test_helper_for_acronym_controller assert_equal "test: baz", call_controller(Fun::PdfController, "test").last.body end
test_helper_for_nested_controller()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 143 def test_helper_for_nested_controller assert_equal "hello: Iz guuut!", call_controller(Fun::GamesController, "render_hello_world").last.body end
test_helper_method()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 128 def test_helper_method assert_nothing_raised { @controller_class.helper_method :delegate_method } assert_includes master_helper_methods, :delegate_method end
test_helper_proxy()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 196 def test_helper_proxy methods = AllHelpersController.helpers.methods # Action View assert_includes methods, :pluralize # abc_helper.rb assert_includes methods, :bare_a # fun/games_helper.rb assert_includes methods, :stratego # fun/pdf_helper.rb assert_includes methods, :foobar end
test_helper_proxy_config()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 228 def test_helper_proxy_config AllHelpersController.config.my_var = "smth" assert_equal "smth", AllHelpersController.helpers.config.my_var end
test_helper_proxy_in_instance()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 212 def test_helper_proxy_in_instance methods = AllHelpersController.new.helpers.methods # Action View assert_includes methods, :pluralize # abc_helper.rb assert_includes methods, :bare_a # fun/games_helper.rb assert_includes methods, :stratego # fun/pdf_helper.rb assert_includes methods, :foobar end
test_lib_helper_methods_after_clear_helpers()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 163 def test_lib_helper_methods_after_clear_helpers assert_nothing_raised do call_controller(JustMeController, "lib") end end
Private Instance Methods
expected_helper_methods()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 235 def expected_helper_methods TestHelper.instance_methods end
master_helper_methods()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 239 def master_helper_methods @controller_class._helpers.instance_methods end
missing_methods()
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 243 def missing_methods expected_helper_methods - master_helper_methods end
test_helper=(helper_module)
click to toggle source
# File actionpack/test/controller/helper_test.rb, line 247 def test_helper=(helper_module) silence_warnings { self.class.const_set("TestHelper", helper_module) } end