diff options
author | Eric Mueller <nevinera@gmail.com> | 2023-11-29 21:51:55 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-12-01 17:52:37 +0000 |
commit | 079dfa1812e0f23a74c86e271245504b069b4c17 (patch) | |
tree | dabe1eeffdf75a99b7ebfe4f5af059b4bfdefc1f /spec | |
parent | e5e1f9813e23c427cf45a25181b2e6d3cf97411a (diff) | |
download | ruby-079dfa1812e0f23a74c86e271245504b069b4c17.tar.gz |
[rubygems/rubygems] major_deprecation accepts :removed_message
If supplied, it uses that in place of the message for the case where the
deprecation version is already past.
https://github.com/rubygems/rubygems/commit/1deb73663c
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/shared_helpers_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/bundler/bundler/shared_helpers_spec.rb b/spec/bundler/bundler/shared_helpers_spec.rb index ae44e48c71..e081385bbe 100644 --- a/spec/bundler/bundler/shared_helpers_spec.rb +++ b/spec/bundler/bundler/shared_helpers_spec.rb @@ -522,4 +522,34 @@ RSpec.describe Bundler::SharedHelpers do end end end + + describe "#major_deprecation" do + before { allow(Bundler).to receive(:bundler_major_version).and_return(37) } + before { allow(Bundler.ui).to receive(:warn) } + + it "prints and raises nothing below the deprecated major version" do + subject.major_deprecation(38, "Message") + subject.major_deprecation(39, "Message", :removed_message => "Removal", :print_caller_location => true) + expect(Bundler.ui).not_to have_received(:warn) + end + + it "prints but does not raise _at_ the deprecated major version" do + subject.major_deprecation(37, "Message") + subject.major_deprecation(37, "Message", :removed_message => "Removal") + expect(Bundler.ui).to have_received(:warn).with("[DEPRECATED] Message").twice + + subject.major_deprecation(37, "Message", :print_caller_location => true) + expect(Bundler.ui).to have_received(:warn). + with(a_string_matching(/^\[DEPRECATED\] Message \(called at .*:\d+\)$/)) + end + + it "raises the appropriate errors when _past_ the deprecated major version" do + expect { subject.major_deprecation(36, "Message") }. + to raise_error(Bundler::DeprecatedError, "[REMOVED] Message") + expect { subject.major_deprecation(36, "Message", :removed_message => "Removal") }. + to raise_error(Bundler::DeprecatedError, "[REMOVED] Removal") + expect { subject.major_deprecation(35, "Message", :removed_message => "Removal", :print_caller_location => true) }. + to raise_error(Bundler::DeprecatedError, /^\[REMOVED\] Removal \(called at .*:\d+\)$/) + end + end end |