Skip to content

Commit

Permalink
! Restore behavior of Gem::Specification#loaded? Ruby Bug #5032
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Jul 23, 2011
1 parent e43c291 commit 8b8644f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .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'
Expand Down
9 changes: 6 additions & 3 deletions lib/rubygems/specification.rb
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions test/rubygems/test_gem_specification.rb
Expand Up @@ -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"
Expand Down

0 comments on commit 8b8644f

Please sign in to comment.