diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-15 02:29:36 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-15 02:29:36 +0000 |
commit | ee0ea35d910174f2a2ce2483672b705960b52f95 (patch) | |
tree | 83ff3f1bb5664d62c859f40f875489d70f71f847 | |
parent | 525cac7f828c432e8f56d56424227b053c78febe (diff) | |
download | rails-ee0ea35d910174f2a2ce2483672b705960b52f95.tar.gz rails-ee0ea35d910174f2a2ce2483672b705960b52f95.tar.bz2 rails-ee0ea35d910174f2a2ce2483672b705960b52f95.zip |
Ruby 1.9 compat: helpers
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/lib/action_controller/helpers.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/helper_test.rb | 14 |
2 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/helpers.rb b/actionpack/lib/action_controller/helpers.rb index 3a559efbc6..81b8ff9753 100644 --- a/actionpack/lib/action_controller/helpers.rb +++ b/actionpack/lib/action_controller/helpers.rb @@ -1,3 +1,4 @@ +# FIXME: helper { ... } is broken on Ruby 1.9 module ActionController #:nodoc: module Helpers #:nodoc: HELPERS_DIR = (defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/app/helpers" : "app/helpers") @@ -120,7 +121,7 @@ module ActionController #:nodoc: begin require_dependency(file_name) rescue LoadError => load_error - requiree = / -- (.*?)(\.rb)?$/.match(load_error).to_a[1] + requiree = / -- (.*?)(\.rb)?$/.match(load_error.message).to_a[1] if requiree == file_name msg = "Missing helper file helpers/#{file_name}.rb" raise LoadError.new(msg).copy_blame!(load_error) diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb index 54e2582ca2..117f73b768 100644 --- a/actionpack/test/controller/helper_test.rb +++ b/actionpack/test/controller/helper_test.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../abstract_unit' -silence_warnings { ActionController::Helpers::HELPERS_DIR = File.dirname(__FILE__) + '/../fixtures/helpers' } +ActionController::Helpers::HELPERS_DIR.replace File.dirname(__FILE__) + '/../fixtures/helpers' class TestController < ActionController::Base attr_accessor :delegate_attr @@ -130,23 +130,25 @@ class HelperTest < Test::Unit::TestCase end def test_all_helpers + methods = ApplicationController.master_helper_module.instance_methods.map(&:to_s) + # abc_helper.rb - assert ApplicationController.master_helper_module.instance_methods.include?("bare_a") + assert methods.include?('bare_a') # fun/games_helper.rb - assert ApplicationController.master_helper_module.instance_methods.include?("stratego") + assert methods.include?('stratego') # fun/pdf_helper.rb - assert ApplicationController.master_helper_module.instance_methods.include?("foobar") + assert methods.include?('foobar') end private def expected_helper_methods - TestHelper.instance_methods + TestHelper.instance_methods.map(&:to_s) end def master_helper_methods - @controller_class.master_helper_module.instance_methods + @controller_class.master_helper_module.instance_methods.map(&:to_s) end def missing_methods |