diff --git a/Rakefile b/Rakefile index 625e6630bf2..5d6edbcbef5 100644 --- a/Rakefile +++ b/Rakefile @@ -51,17 +51,10 @@ namespace :spec do deps.delete("rdiscount") end - if Gem::VERSION < "2.0.0" - deps.sort_by {|name, _| name }.map do |name, version| - gem_install_command = "install --no-ri --no-rdoc --conservative #{name} -v '#{version}'" - sh %(#{Gem.ruby} -S gem #{gem_install_command}) - end - else - gem_install_command = "install --no-document --conservative " + deps.sort_by {|name, _| name }.map do |name, version| - "'#{name}:#{version}'" - end.join(" ") - sh %(#{Gem.ruby} -S gem #{gem_install_command}) - end + gem_install_command = "install --no-document --conservative " + deps.sort_by {|name, _| name }.map do |name, version| + "'#{name}:#{version}'" + end.join(" ") + sh %(#{Gem.ruby} -S gem #{gem_install_command}) # Download and install gems used inside tests $LOAD_PATH.unshift("./spec") diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt index 113bf82eb2f..c1a50fe9126 100644 --- a/lib/bundler/templates/newgem/newgem.gemspec.tt +++ b/lib/bundler/templates/newgem/newgem.gemspec.tt @@ -21,18 +21,11 @@ Gem::Specification.new do |spec| spec.license = "MIT" <%- end -%> - # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' - # to allow pushing to a single host or delete this section to allow pushing to any host. - if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" + spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." - spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." - else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." - end + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." + spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb index 3620035fe1d..e2cd7e8bc64 100644 --- a/spec/bundler/gem_helper_spec.rb +++ b/spec/bundler/gem_helper_spec.rb @@ -29,15 +29,6 @@ end context "interpolates the name" do - before do - # Remove exception that prevents public pushes on older RubyGems versions - if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0") - content = File.read(app_gemspec_path) - content.sub!(/raise "RubyGems 2\.0 or newer.*/, "") - File.open(app_gemspec_path, "w") {|f| f.write(content) } - end - end - it "when there is only one gemspec" do expect(subject.gemspec.name).to eq(app_name) end @@ -72,7 +63,7 @@ def mock_build_message(name, version) let(:app_version) { "0.1.0" } let(:app_gem_dir) { app_path.join("pkg") } let(:app_gem_path) { app_gem_dir.join("#{app_name}-#{app_version}.gem") } - let(:app_gemspec_content) { remove_push_guard(File.read(app_gemspec_path)) } + let(:app_gemspec_content) { File.read(app_gemspec_path) } before(:each) do content = app_gemspec_content.gsub("TODO: ", "") @@ -81,14 +72,6 @@ def mock_build_message(name, version) File.open(app_gemspec_path, "w") {|file| file << content } end - def remove_push_guard(gemspec_content) - # Remove exception that prevents public pushes on older RubyGems versions - if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0") - gemspec_content.sub!(/raise "RubyGems 2\.0 or newer.*/, "") - end - gemspec_content - end - it "uses a shell UI for output" do expect(Bundler.ui).to be_a(Bundler::UI::Shell) end diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 598d68ec3ab..8f033e5b4f7 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -6,18 +6,8 @@ def reset! global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false" end - def remove_push_guard(gem_name) - # Remove exception that prevents public pushes on older RubyGems versions - if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0") - path = "#{gem_name}/#{gem_name}.gemspec" - content = File.read(path).sub(/raise "RubyGems 2\.0 or newer.*/, "") - File.open(path, "w") {|f| f.write(content) } - end - end - - def execute_bundle_gem(gem_name, flag = "", to_remove_push_guard = true) + def execute_bundle_gem(gem_name, flag = "") bundle! "gem #{gem_name} #{flag}" - remove_push_guard(gem_name) if to_remove_push_guard # reset gemspec cache for each test because of commit 3d4163a Bundler.clear_gemspec_cache end @@ -96,7 +86,7 @@ def gem_skeleton_assertions(gem_name) shared_examples_for "--coc flag" do before do - execute_bundle_gem(gem_name, "--coc", false) + execute_bundle_gem(gem_name, "--coc") end it "generates a gem skeleton with MIT license" do gem_skeleton_assertions(gem_name) @@ -113,7 +103,7 @@ def gem_skeleton_assertions(gem_name) shared_examples_for "--no-coc flag" do before do - execute_bundle_gem(gem_name, "--no-coc", false) + execute_bundle_gem(gem_name, "--no-coc") end it "generates a gem skeleton without Code of Conduct" do gem_skeleton_assertions(gem_name) @@ -149,7 +139,6 @@ def gem_skeleton_assertions(gem_name) reset! in_app_root bundle "gem #{gem_name}" - remove_push_guard(gem_name) end it "contribute URL set to [USERNAME]" do @@ -202,9 +191,6 @@ def gem_skeleton_assertions(gem_name) line.gsub(/\=.*$/, "= %q{A short summary of my new gem.}") when /spec\.description/ line.gsub(/\=.*$/, "= %q{A longer description of my new gem.}") - # Remove exception that prevents public pushes on older RubyGems versions - when /raise "RubyGems 2.0 or newer/ - line.gsub(/.*/, "") if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.0") else line end @@ -295,7 +281,6 @@ def create_temporary_dir(dir) reset! in_app_root bundle "gem #{gem_name}" - remove_push_guard(gem_name) end it_should_behave_like "git config is absent" @@ -394,7 +379,6 @@ def create_temporary_dir(dir) end it "depends on a specific version of rspec", :rubygems => ">= 1.8.1" do - remove_push_guard(gem_name) rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "rspec" } expect(rspec_dep).to be_specific end @@ -445,7 +429,6 @@ def create_temporary_dir(dir) end it "depends on a specific version of minitest", :rubygems => ">= 1.8.1" do - remove_push_guard(gem_name) rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "minitest" } expect(rspec_dep).to be_specific end @@ -589,7 +572,6 @@ def create_temporary_dir(dir) reset! in_app_root bundle "gem #{gem_name}" - remove_push_guard(gem_name) end it_should_behave_like "git config is absent" diff --git a/spec/commands/pristine_spec.rb b/spec/commands/pristine_spec.rb index de3cb8054bf..3ce6636f9f7 100644 --- a/spec/commands/pristine_spec.rb +++ b/spec/commands/pristine_spec.rb @@ -48,9 +48,7 @@ bundle! "install" bundle! "pristine", :system_bundler => true bundle! "-v", :system_bundler => true - # An old rubygems couldn't handle a correct version of vendoered bundler. - bundler_version = Gem::VERSION < "2.1" ? "1.16.0" : Bundler::VERSION - expect(out).to end_with(bundler_version) + expect(out).to end_with(Bundler::VERSION) end end diff --git a/spec/support/builders.rb b/spec/support/builders.rb index fa32b12b652..188b1d3eb77 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -210,12 +210,7 @@ def build_repo1 # The yard gem iterates over Gem.source_index looking for plugins build_gem "yard" do |s| s.write "lib/yard.rb", <<-Y - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.10") - specs = Gem::Specification - else - specs = Gem.source_index.find_name('') - end - specs.sort_by(&:name).each do |gem| + Gem::Specification.sort_by(&:name).each do |gem| puts gem.full_name end Y diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 87d61525222..cb73bfdc4e8 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -322,11 +322,8 @@ def install_gems(*gems) raise "OMG `#{path}` does not exist!" unless File.exist?(path) - if Gem::VERSION < "2.0.0" - gem_command! :install, "--no-rdoc --no-ri --ignore-dependencies '#{path}'" - else - gem_command! :install, "--no-document --ignore-dependencies '#{path}'" - end + gem_command! :install, "--no-document --ignore-dependencies '#{path}'" + bundler_path && bundler_path.rmtree end end diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index eff142118f8..7a69d713cb6 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -59,11 +59,7 @@ def self.install_gems(gems) no_reqs.map!(&:first) reqs.map! {|name, req| "'#{name}:#{req}'" } deps = reqs.concat(no_reqs).join(" ") - cmd = if Gem::VERSION < "2.0.0" - "#{Gem.ruby} -S gem install #{deps} --no-rdoc --no-ri --conservative" - else - "#{Gem.ruby} -S gem install #{deps} --no-document --conservative" - end + cmd = "#{Gem.ruby} -S gem install #{deps} --no-document --conservative" puts cmd system(cmd) || raise("Installing gems #{deps} for the tests to use failed!") end