diff options
-rw-r--r-- | lib/rubygems/specification.rb | 5 | ||||
-rw-r--r-- | lib/rubygems/specification_policy.rb | 10 | ||||
-rw-r--r-- | test/rubygems/test_gem_specification.rb | 20 |
3 files changed, 32 insertions, 3 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 18e3f2d20d..6ff9a89699 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -728,12 +728,11 @@ class Gem::Specification < Gem::BasicSpecification attr_writer :original_platform # :nodoc: ## - # Deprecated and ignored. + # Deprecated via specification policy and ignored during runtime. # # Formerly used to set rubyforge project. - attr_writer :rubyforge_project - rubygems_deprecate :rubyforge_project= + attr_accessor :rubyforge_project ## # The Gem::Specification version of this gemspec. diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index d9f415d25f..8d4958c001 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -21,6 +21,8 @@ class Gem::SpecificationPolicy funding_uri ].freeze # :nodoc: + DEPRECATED_ATTRIBUTES = [:rubyforge_project].freeze #:nodoc: + def initialize(specification) @warnings = 0 @@ -76,6 +78,8 @@ class Gem::SpecificationPolicy validate_dependencies + validate_deprecated_attributes + if @warnings > 0 if strict error "specification has warnings" @@ -409,6 +413,12 @@ http://spdx.org/licenses or '#{Gem::Licenses::NONSTANDARD}' for a nonstandard li warning "#{executable_path} is missing #! line" end + def validate_deprecated_attributes # :nodoc: + DEPRECATED_ATTRIBUTES.each do |attr| + warning("#{attr} is deprecated") unless @specification.send(attr).nil? + end + end + def warning(statement) # :nodoc: @warnings += 1 diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 1848e52e16..cf4a4de6c9 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3128,6 +3128,26 @@ http://spdx.org/licenses or 'Nonstandard' for a nonstandard license. warning end + def test_deprecated_attributes + assert_equal Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES, [:rubyforge_project] + end + + def test_validate_deprecated_attributes + util_setup_validate + + use_ui @ui do + Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES.each do |attr| + @a1.send("#{attr}=", 'invalid-attribute') + end + + @a1.validate + end + + Gem::SpecificationPolicy::DEPRECATED_ATTRIBUTES.each do |attr| + assert_match "#{attr} is deprecated", @ui.error + end + end + def test_validate_license_values util_setup_validate |