Skip to content
Browse files

Allow Pathnames to be added to eager load paths

  • Loading branch information...
1 parent eb6dd34 commit ec3134739c6bf7cf6482feb46155293e2b09c45b @mikepack mikepack committed Oct 29, 2013
View
4 railties/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Support for Pathnames in eager load paths.
+
+ *Mike Pack*
+
* Fixed missing line and shadow on service pages(404, 422, 500).
*Dmitry Korotkov*
View
2 railties/lib/rails/engine.rb
@@ -465,7 +465,7 @@ def load_generators(app=self)
# files inside eager_load paths.
def eager_load!
config.eager_load_paths.each do |load_path|
- matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/
+ matcher = /\A#{Regexp.escape(load_path.to_s)}\/(.*)\.rb\Z/
Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
require_dependency file.sub(matcher, '\1')
end
View
14 railties/test/application/initializers/load_path_test.rb
@@ -71,6 +71,20 @@ module Zoo::ReptileHouse ; end
assert Zoo
end
+ test "eager loading accepts Pathnames" do
+ app_file "lib/foo.rb", <<-RUBY
+ module Foo; end
+ RUBY
+
+ add_to_config <<-RUBY
+ config.eager_load = true
+ config.eager_load_paths << Pathname.new("#{app_path}/lib")
+ RUBY
+
+ require "#{app_path}/config/environment"
+ assert Foo
+ end
+
test "load environment with global" do
$initialize_test_set_from_env = nil
app_file "config/environments/development.rb", <<-RUBY

0 comments on commit ec31347

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