aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb2
-rw-r--r--actionpack/test/controller/new_base/base_test.rb2
-rw-r--r--activemodel/lib/active_model/lint.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/load_error.rb46
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/test/core_ext/load_error_test.rb15
6 files changed, 36 insertions, 33 deletions
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index d0402e5bad..cdd14560e1 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -100,7 +100,7 @@ module ActionController
module_path = module_name.underscore
helper module_path
rescue MissingSourceFile => e
- raise e unless e.is_missing? "#{module_path}_helper"
+ raise e unless e.is_missing? "helpers/#{module_path}_helper"
rescue NameError => e
raise e unless e.missing_name? "#{module_name}Helper"
end
diff --git a/actionpack/test/controller/new_base/base_test.rb b/actionpack/test/controller/new_base/base_test.rb
index 579f9f349f..0b40f8ce95 100644
--- a/actionpack/test/controller/new_base/base_test.rb
+++ b/actionpack/test/controller/new_base/base_test.rb
@@ -22,7 +22,7 @@ module Dispatching
end
def show_actions
- render :text => "actions: #{action_methods.to_a.join(', ')}"
+ render :text => "actions: #{action_methods.to_a.sort.join(', ')}"
end
protected
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb
index 0be82aa180..1330bf7042 100644
--- a/activemodel/lib/active_model/lint.rb
+++ b/activemodel/lib/active_model/lint.rb
@@ -53,6 +53,8 @@ module ActiveModel
assert_kind_of String, model_name
assert_kind_of String, model_name.human
assert_kind_of String, model_name.partial_path
+ assert_kind_of String, model_name.singular
+ assert_kind_of String, model_name.plural
end
# errors
diff --git a/activesupport/lib/active_support/core_ext/load_error.rb b/activesupport/lib/active_support/core_ext/load_error.rb
index cc6287b100..615ebe9588 100644
--- a/activesupport/lib/active_support/core_ext/load_error.rb
+++ b/activesupport/lib/active_support/core_ext/load_error.rb
@@ -1,36 +1,22 @@
-class MissingSourceFile < LoadError #:nodoc:
- attr_reader :path
- def initialize(message, path)
- super(message)
- @path = path
- end
-
- def is_missing?(path)
- path.gsub(/\.rb$/, '') == self.path.gsub(/\.rb$/, '')
- end
+class LoadError
+ REGEXPS = [
+ /^no such file to load -- (.+)$/i,
+ /^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
+ /^Missing API definition file in (.+)$/i,
+ ]
- def self.from_message(message)
- REGEXPS.each do |regexp, capture|
- match = regexp.match(message)
- return MissingSourceFile.new(message, match[capture]) unless match.nil?
+ def path
+ @path ||= begin
+ REGEXPS.find do |regex|
+ message =~ regex
+ end
+ $1
end
- nil
end
- REGEXPS = [
- [/^no such file to load -- (.+)$/i, 1],
- [/^Missing \w+ (file\s*)?([^\s]+.rb)$/i, 2],
- [/^Missing API definition file in (.+)$/i, 1],
- [/win32/, 0]
- ] unless defined?(REGEXPS)
-end
-
-class LoadError
- def self.new(*args)
- if self == LoadError
- MissingSourceFile.from_message(args.first)
- else
- super
- end
+ def is_missing?(location)
+ location.sub(/\.rb$/, '') == path.sub(/\.rb$/, '')
end
end
+
+MissingSourceFile = LoadError \ No newline at end of file
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index e858bcdc80..8ded9f8b2d 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -236,7 +236,7 @@ module ActiveSupport #:nodoc:
rescue LoadError => load_error
unless swallow_load_errors
if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
- raise MissingSourceFile.new(message % file_name, load_error.path).copy_blame!(load_error)
+ raise LoadError.new(message % file_name).copy_blame!(load_error)
end
raise
end
diff --git a/activesupport/test/core_ext/load_error_test.rb b/activesupport/test/core_ext/load_error_test.rb
index b775b65f9f..d7b8f602ca 100644
--- a/activesupport/test/core_ext/load_error_test.rb
+++ b/activesupport/test/core_ext/load_error_test.rb
@@ -15,3 +15,18 @@ class TestMissingSourceFile < Test::Unit::TestCase
end
end
end
+
+class TestLoadError < Test::Unit::TestCase
+ def test_with_require
+ assert_raise(LoadError) { require 'no_this_file_don\'t_exist' }
+ end
+ def test_with_load
+ assert_raise(LoadError) { load 'nor_does_this_one' }
+ end
+ def test_path
+ begin load 'nor/this/one.rb'
+ rescue LoadError => e
+ assert_equal 'nor/this/one.rb', e.path
+ end
+ end
+end \ No newline at end of file