diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index 3a82202bd0..3cc75494e4 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -34,7 +34,7 @@ module Rails name = directory_name_parts[0..-2].join('-') version = directory_name_parts.last result = self.new(name, :version => version) - spec_filename = File.join(unpacked_path, directory_name, '.specification') + spec_filename = File.join(directory_name, '.specification') if load_spec raise "Missing specification file in #{File.dirname(spec_filename)}. Perhaps you need to do a 'rake gems:refresh_specs'?" unless File.exists?(spec_filename) spec = YAML::load_file(spec_filename) diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb index 195494a926..70f4496685 100644 --- a/railties/test/gem_dependency_test.rb +++ b/railties/test/gem_dependency_test.rb @@ -178,6 +178,13 @@ class GemDependencyTest < Test::Unit::TestCase assert_equal '= 1.1', dummy_gem.version_requirements.to_s end + def test_gem_from_directory_name_loads_specification_successfully + assert_nothing_raised do + dummy_gem = Rails::GemDependency.from_directory_name(File.join(Rails::GemDependency.unpacked_path, 'dummy-gem-g-1.0.0')) + assert_not_nil dummy_gem.specification + end + end + def test_gem_from_invalid_directory_name assert_raises RuntimeError do dummy_gem = Rails::GemDependency.from_directory_name('dummy-gem')