mirror of
https://github.com/github/rails.git
synced 2026-01-27 15:28:00 -05:00
Ruby 1.9 compat: helpers
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8409 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user