Skip to content
This repository
Browse code

handle missing dependecies in gem loading

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit 3c07a8828ede3d41000513af29c293ae2e2a49d4 1 parent 0a4a5f3
Matt Jones authored NZKoz committed
1  railties/lib/rails/gem_dependency.rb
@@ -74,6 +74,7 @@ def add_load_paths
74 74
 
75 75
     def dependencies
76 76
       return [] if framework_gem?
  77
+      return [] if specification.nil?
77 78
       all_dependencies = specification.dependencies.map do |dependency|
78 79
         GemDependency.new(dependency.name, :requirement => dependency.version_requirements)
79 80
       end
14  railties/test/gem_dependency_test.rb
@@ -129,5 +129,19 @@ def test_gem_load_bad_specification
129 129
       assert_equal '1.0.0', DUMMY_GEM_E_VERSION
130 130
     end
131 131
 
  132
+    def test_gem_handle_missing_dependencies
  133
+      dummy_gem = Rails::GemDependency.new "dummy-gem-g"
  134
+      dummy_gem.add_load_paths
  135
+      dummy_gem.load
  136
+      assert dummy_gem.loaded?
  137
+      debugger
  138
+      assert_equal 2, dummy_gem.dependencies.size
  139
+      assert_nothing_raised do
  140
+        dummy_gem.dependencies.each do |g|
  141
+          g.dependencies
  142
+        end
  143
+      end
  144
+    end
  145
+
132 146
   end
133 147
 end
39  railties/test/vendor/gems/dummy-gem-f-1.0.0/.specification
... ...
@@ -0,0 +1,39 @@
  1
+--- !ruby/object:Gem::Specification
  2
+name: dummy-gem-f
  3
+version: !ruby/object:Gem::Version
  4
+  version: 1.3.0
  5
+platform: ruby
  6
+authors:
  7
+- "Nobody"
  8
+date: 2008-10-03 00:00:00 -04:00
  9
+dependencies:
  10
+- !ruby/object:Gem::Dependency
  11
+  name: absolutely-no-such-gem
  12
+  type: :runtime
  13
+  version_requirement:
  14
+  version_requirements: !ruby/object:Gem::Requirement
  15
+    requirements:
  16
+    - - ">="
  17
+      - !ruby/object:Gem::Version
  18
+        version: 1.0.0
  19
+    version:
  20
+files:
  21
+- lib
  22
+- lib/dummy-gem-f.rb
  23
+require_paths:
  24
+- lib
  25
+required_ruby_version: !ruby/object:Gem::Requirement
  26
+  requirements:
  27
+  - - ">="
  28
+    - !ruby/object:Gem::Version
  29
+      version: "0"
  30
+  version:
  31
+required_rubygems_version: !ruby/object:Gem::Requirement
  32
+  requirements:
  33
+  - - ">="
  34
+    - !ruby/object:Gem::Version
  35
+      version: "0"
  36
+  version:
  37
+requirements: []
  38
+specification_version: 2
  39
+summary: Dummy Gem F
1  railties/test/vendor/gems/dummy-gem-f-1.0.0/lib/dummy-gem-f.rb
... ...
@@ -0,0 +1 @@
  1
+DUMMY_GEM_F_VERSION="1.0.0"
39  railties/test/vendor/gems/dummy-gem-g-1.0.0/.specification
... ...
@@ -0,0 +1,39 @@
  1
+--- !ruby/object:Gem::Specification
  2
+name: dummy-gem-g
  3
+version: !ruby/object:Gem::Version
  4
+  version: 1.3.0
  5
+platform: ruby
  6
+authors:
  7
+- "Nobody"
  8
+date: 2008-10-03 00:00:00 -04:00
  9
+dependencies:
  10
+- !ruby/object:Gem::Dependency
  11
+  name: dummy-gem-f
  12
+  type: :development
  13
+  version_requirement:
  14
+  version_requirements: !ruby/object:Gem::Requirement
  15
+    requirements:
  16
+    - - ">="
  17
+      - !ruby/object:Gem::Version
  18
+        version: 1.0.0
  19
+    version:
  20
+files:
  21
+- lib
  22
+- lib/dummy-gem-g.rb
  23
+require_paths:
  24
+- lib
  25
+required_ruby_version: !ruby/object:Gem::Requirement
  26
+  requirements:
  27
+  - - ">="
  28
+    - !ruby/object:Gem::Version
  29
+      version: "0"
  30
+  version:
  31
+required_rubygems_version: !ruby/object:Gem::Requirement
  32
+  requirements:
  33
+  - - ">="
  34
+    - !ruby/object:Gem::Version
  35
+      version: "0"
  36
+  version:
  37
+requirements: []
  38
+specification_version: 2
  39
+summary: Dummy Gem G
1  railties/test/vendor/gems/dummy-gem-g-1.0.0/lib/dummy-gem-g.rb
... ...
@@ -0,0 +1 @@
  1
+DUMMY_GEM_G_VERSION="1.0.0"

0 notes on commit 3c07a88

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