Skip to content
Browse files

Ruby 1.9 compat: helpers

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 525cac7 commit ee0ea35d910174f2a2ce2483672b705960b52f95 @jeremy jeremy committed Dec 15, 2007
Showing with 10 additions and 7 deletions.
  1. +2 −1 actionpack/lib/action_controller/helpers.rb
  2. +8 −6 actionpack/test/controller/helper_test.rb
View
3 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 @@ def helper(*args, &block)
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)
View
14 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 @@ def test_helper_for_acronym_controller
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

0 comments on commit ee0ea35

Please sign in to comment.
Something went wrong with that request. Please try again.