summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-07-01 12:11:36 -0300
committerSamuel Giddins <segiddins@segiddins.me>2016-07-05 15:11:19 -0300
commitd88627a8191644fb970cce2140f3c320f3101c32 (patch)
treecb4455357dafd59963eb2dc624353ae907ebe932
parent56c3b82d5ee5f6577ded051a9778b9aeeae14ab7 (diff)
downloadbundler-d88627a8191644fb970cce2140f3c320f3101c32.tar.gz
Clean up outdated deprecation code
-rw-r--r--lib/bundler/source_list.rb6
-rw-r--r--lib/bundler/ui/shell.rb9
-rw-r--r--lib/bundler/ui/silent.rb3
-rw-r--r--spec/bundler/bundler_spec.rb60
-rw-r--r--spec/commands/console_spec.rb8
-rw-r--r--spec/install/gemfile/sources_spec.rb9
-rw-r--r--spec/other/major_deprecation_spec.rb19
-rw-r--r--spec/support/matchers.rb17
8 files changed, 35 insertions, 96 deletions
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index 37ce5f3a79..b6ce6029c8 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -22,9 +22,9 @@ module Bundler
end
def add_git_source(options = {})
- source = add_source_to_list(Source::Git.new(options), git_sources)
- warn_on_git_protocol(source)
- source
+ add_source_to_list(Source::Git.new(options), git_sources).tap do |source|
+ warn_on_git_protocol(source)
+ end
end
def add_rubygems_source(options = {})
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 8db69c47d0..195bd56a5c 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -6,7 +6,7 @@ module Bundler
class Shell
LEVELS = %w(silent error warn confirm info debug).freeze
- attr_writer :shell, :deprecation_messages
+ attr_writer :shell
def initialize(options = {})
if options["no-color"] || !STDOUT.tty?
@@ -15,7 +15,6 @@ module Bundler
@shell = Thor::Base.shell.new
@level = ENV["DEBUG"] ? "debug" : "info"
@warning_history = []
- @deprecation_messages = Set.new
end
def add_color(string, color)
@@ -36,12 +35,6 @@ module Bundler
tell_me(msg, :yellow, newline) if level("warn")
end
- def deprecate(msg, newline = nil)
- return if @deprecation_messages.include?(msg)
- @deprecation_messages.add(msg)
- tell_err("DEPRECATION: " + msg, :yellow, newline)
- end
-
def error(msg, newline = nil)
tell_me(msg, :red, newline) if level("error")
end
diff --git a/lib/bundler/ui/silent.rb b/lib/bundler/ui/silent.rb
index 7e40749fe1..367eaa58c2 100644
--- a/lib/bundler/ui/silent.rb
+++ b/lib/bundler/ui/silent.rb
@@ -15,9 +15,6 @@ module Bundler
def warn(message, newline = nil)
end
- def deprecate(message, newline = nil)
- end
-
def error(message, newline = nil)
end
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 83db582c0a..f338b5268d 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -4,66 +4,6 @@ require "spec_helper"
require "bundler"
describe Bundler do
- describe "version 1.99" do
- context "when bundle is run" do
- it "should print a single deprecation warning" do
- # install_gemfile calls `bundle :install, opts`
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
- G
-
- expect(out).to include("DEPRECATION: Gemfile and Gemfile.lock are " \
- "deprecated and will be replaced with gems.rb and gems.locked in " \
- "Bundler 2.0.0.")
- expect(err).to lack_errors
- end
- end
-
- context "when Bundler.setup is run in a ruby script" do
- it "should print a single deprecation warning" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", :group => :test
- G
-
- ruby <<-RUBY
- require 'rubygems'
- require 'bundler'
- require 'bundler/vendored_thor'
-
- Bundler.ui = Bundler::UI::Shell.new
- Bundler.setup
- Bundler.setup
- RUBY
-
- expect(out).to eq("DEPRECATION: Gemfile and Gemfile.lock are " \
- "deprecated and will be replaced with gems.rb and gems.locked in " \
- "Bundler 2.0.0.")
- expect(err).to lack_errors
- end
- end
-
- context "when `bundler/deployment` is required in a ruby script" do
- it "should print a capistrano deprecation warning" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack", :group => :test
- G
-
- ruby(<<-RUBY, :expect_err => true)
- require 'bundler/deployment'
- RUBY
-
- expect(err).to include("DEPRECATION: Bundler no longer integrates " \
- "with Capistrano, but Capistrano provides " \
- "its own integration with Bundler via the " \
- "capistrano-bundler gem. Use it instead.")
- expect(err).to lack_errors
- end
- end
- end
-
describe "#load_gemspec_uncached" do
let(:app_gemspec_path) { tmp("test.gemspec") }
subject { Bundler.load_gemspec_uncached(app_gemspec_path) }
diff --git a/spec/commands/console_spec.rb b/spec/commands/console_spec.rb
index 6bf09f243b..b60ac2c9f6 100644
--- a/spec/commands/console_spec.rb
+++ b/spec/commands/console_spec.rb
@@ -11,14 +11,6 @@ describe "bundle console" do
G
end
- it "prints a deprecation warning" do
- bundle "console"
-
- expect(err).to include("bundle console is deprecated and will be replaced " \
- "by `bin/console` generated by `bundle gem <name>` " \
- "in Bundler 2.0.")
- end
-
it "starts IRB with the default group loaded" do
bundle "console" do |input, _, _|
input.puts("puts RACK")
diff --git a/spec/install/gemfile/sources_spec.rb b/spec/install/gemfile/sources_spec.rb
index 7411538955..70ea9e30ce 100644
--- a/spec/install/gemfile/sources_spec.rb
+++ b/spec/install/gemfile/sources_spec.rb
@@ -26,12 +26,13 @@ describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack"
G
+ bundle "config major_deprecations true"
end
it "warns about ambiguous gems, but installs anyway, prioritizing sources last to first" do
bundle :install
- expect(err).to include("DEPRECATION: Your Gemfile contains multiple primary sources.")
+ expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo1}")
should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
@@ -55,12 +56,13 @@ describe "bundle install with gems on multiple sources" do
gem "rack-obama"
gem "rack", "1.0.0" # force it to install the working version in repo1
G
+ bundle "config major_deprecations true"
end
it "warns about ambiguous gems, but installs anyway" do
bundle :install
- expect(err).to include("DEPRECATION: Your Gemfile contains multiple primary sources.")
+ expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo1}")
should_be_installed("rack-obama 1.0.0", "rack 1.0.0")
@@ -223,8 +225,9 @@ describe "bundle install with gems on multiple sources" do
end
it "installs from the other source and warns about ambiguous gems" do
+ bundle "config major_deprecations true"
bundle :install
- expect(err).to include("DEPRECATION: Your Gemfile contains multiple primary sources.")
+ expect(out).to have_major_deprecation a_string_including("Your Gemfile contains multiple primary sources.")
expect(out).to include("Warning: the gem 'rack' was found in multiple sources.")
expect(out).to include("Installed from: file:#{gem_repo2}")
should_be_installed("depends_on_rack 1.0.1", "rack 1.0.0")
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index 74f4d0e0d7..7e11e3a30a 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -2,15 +2,6 @@
require "spec_helper"
describe "major deprecations" do
- matcher :have_major_deprecation do |expected|
- diffable
- match do |actual|
- actual.split(/^\[DEPRECATED FOR 2\.0\]\s*/).any? do |d|
- !d.empty? && values_match?(expected, d.strip)
- end
- end
- end
-
let(:warnings) { out } # change to err in 2.0
before do
@@ -220,4 +211,14 @@ describe "major deprecations" do
expect(warnings).to have_major_deprecation("use `bundle show` instead of `bundle list`")
end
end
+
+ context "bundle console" do
+ it "prints a deprecation warning" do
+ bundle "console"
+
+ expect(warnings).to have_major_deprecation("bundle console is deprecated and will be replaced " \
+ "by `bin/console` generated by `bundle gem <name>` " \
+ "in Bundler 2.0.")
+ end
+ end
end
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 186caa03ab..ac91874cfa 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -1,15 +1,28 @@
# frozen_string_literal: true
module Spec
module Matchers
+ MAJOR_DEPRECATION = /^\[DEPRECATED FOR 2\.0\]\s*/
+
RSpec::Matchers.define :lack_errors do
+ diffable
match do |actual|
- actual.gsub(/(^DEPRECATION:.+[\n]?)/, "") == ""
+ actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == ""
end
end
RSpec::Matchers.define :eq_err do |expected|
+ diffable
+ match do |actual|
+ actual.gsub(/#{MAJOR_DEPRECATION}.+[\n]?/, "") == expected
+ end
+ end
+
+ RSpec::Matchers.define :have_major_deprecation do |expected|
+ diffable
match do |actual|
- actual.gsub(/(^DEPRECATION:.+\n)/, "") == expected
+ actual.split(MAJOR_DEPRECATION).any? do |d|
+ !d.empty? && values_match?(expected, d.strip)
+ end
end
end