Permalink
Browse files

! Restore behavior of Gem::Specification#loaded? Ruby Bug #5032

  • Loading branch information...
1 parent e43c291 commit 8b8644fafbe11675d0719dac37e1c4b3cd247819 @drbrain drbrain committed Jul 23, 2011
Showing with 17 additions and 4 deletions.
  1. +1 −1 .autotest
  2. +6 −3 lib/rubygems/specification.rb
  3. +10 −0 test/rubygems/test_gem_specification.rb
View
2 .autotest
@@ -1,9 +1,9 @@
# -*- ruby -*-
-ENV['GEM_HOME'] = "tmp/isolate/ruby-1.8"
Gem.refresh
require 'autotest/restart'
+require 'autotest/isolate'
Autotest.add_hook :initialize do |at|
at.testlib = 'minitest/autorun'
View
9 lib/rubygems/specification.rb
@@ -576,9 +576,9 @@ def test_files= files
##
# True when this gemspec has been activated. This attribute is not persisted.
- attr_accessor :loaded
+ attr_accessor :loaded # :nodoc:
- alias :loaded? :loaded
+ alias :loaded? :loaded # :nodoc:
##
# Path this gemspec was loaded from. This attribute is not persisted.
@@ -1045,6 +1045,7 @@ def self._load(str)
spec.instance_variable_set :@license, array[17]
spec.instance_variable_set :@metadata, array[18]
spec.instance_variable_set :@loaded, false
+ spec.instance_variable_set :@activated, false
spec
end
@@ -1105,7 +1106,8 @@ def activate
add_self_to_load_path
Gem.loaded_specs[self.name] = self
- self.activated = true
+ @activated = true
+ @loaded = true
return true
end
@@ -1608,6 +1610,7 @@ def init_with coder # :nodoc:
def initialize name = nil, version = nil
@loaded = false
+ @activated = false
@loaded_from = nil
@original_platform = nil
View
10 test/rubygems/test_gem_specification.rb
@@ -335,6 +335,16 @@ def test__dump
assert_equal 'old_platform', same_spec.original_platform
end
+ def test_activate
+ @a2.activate
+
+ assert @a2.activated?
+
+ Gem::Deprecate.skip_during do
+ assert @a2.loaded?
+ end
+ end
+
def test_add_dependency_with_explicit_type
gem = quick_spec "awesome", "1.0" do |awesome|
awesome.add_development_dependency "monkey"

0 comments on commit 8b8644f

Please sign in to comment.