aboutsummaryrefslogtreecommitdiffstats
path: root/spec/commands
diff options
context:
space:
mode:
authorchrismo <chrismo@clabs.org>2016-10-06 09:39:07 -0500
committerchrismo <chrismo@clabs.org>2016-10-12 17:49:00 -0500
commitb8c23f39399d8a6296ea268e7fcd57d3ac712467 (patch)
tree35ca18e4d7f9ad936bff9c60d66d041d79620f6f /spec/commands
parentc0f7f128a55ef3165da52b44f1b82fca80de3238 (diff)
downloadbundler-b8c23f39399d8a6296ea268e7fcd57d3ac712467.tar.gz
Enable cons updates in outdated and other fixes.
Fixes #4772 - Changes previous `--patch` / `--minor` / `--major` options to `--filter-patch` / `--filter-minor` / `--filter-major` and adds back `--patch` / `--minor` / `--major` as conservative the patch level update options to match the behavior of these options in `bundle update` in 1.13. This is a breaking change for the previous filtering options added in 1.12, but we're allowing it because there was some confusion as to what those options did in 1.12, some thinking that it would perform the resolution constraints that these options _now_ actually do. A problem with merging in conservative bundle update options was the pre-existing `--strict` `outdated` option, which has been in `outdated` since 1.5. `--strict` for `outdated` means to only report on newer gem versions that still satisfy declared requirements in the Gemfile. Without `--strict`, `outdated` reports the most recent available regardless of declared requirements in the Gemfile. `--strict` in `update` in 1.13 means to not allow _any_ dependency to update past the patch level option. Rather than break the longer standing `--strict` option, the new `--update-strict` option has been added which maps to the conservative bundle update `--strict` option. We can revisit this in 2.0. This also fixes #5065, where the new filtering options were ignored if the `--strict` option was used.
Diffstat (limited to 'spec/commands')
-rw-r--r--spec/commands/outdated_spec.rb188
1 files changed, 174 insertions, 14 deletions
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index ab00e64b..f95e0fd7 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -309,6 +309,62 @@ describe "bundle outdated" do
expect(out).to_not include("rack (1.2")
end
+
+ describe "and filter options" do
+ it "only reports gems that match requirement and patch filter level" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport", "~> 2.3"
+ gem "weakling", ">= 0.0.1"
+ G
+
+ update_repo2 do
+ build_gem "activesupport", %w(2.4.0 3.0.0)
+ build_gem "weakling", "0.0.5"
+ end
+
+ bundle "outdated --strict --filter-patch"
+
+ expect(out).to_not include("activesupport (newest")
+ expect(out).to include("(newest 0.0.5, installed 0.0.3)")
+ end
+
+ it "only reports gems that match requirement and minor filter level" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport", "~> 2.3"
+ gem "weakling", ">= 0.0.1"
+ G
+
+ update_repo2 do
+ build_gem "activesupport", %w(2.3.9)
+ build_gem "weakling", "0.1.5"
+ end
+
+ bundle "outdated --strict --filter-minor"
+
+ expect(out).to_not include("activesupport (newest")
+ expect(out).to include("(newest 0.1.5, installed 0.0.3)")
+ end
+
+ it "only reports gems that match requirement and major filter level" do
+ install_gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport", "~> 2.3"
+ gem "weakling", ">= 0.0.1"
+ G
+
+ update_repo2 do
+ build_gem "activesupport", %w(2.4.0 2.5.0)
+ build_gem "weakling", "1.1.5"
+ end
+
+ bundle "outdated --strict --filter-major"
+
+ expect(out).to_not include("activesupport (newest")
+ expect(out).to include("(newest 1.1.5, installed 0.0.3)")
+ end
+ end
end
describe "with invalid gem name" do
@@ -456,59 +512,163 @@ describe "bundle outdated" do
it_behaves_like "no version updates are detected"
end
- describe "with --major option" do
- subject { bundle "outdated --major" }
+ describe "with --filter-major option" do
+ subject { bundle "outdated --filter-major" }
it_behaves_like "major version updates are detected"
it_behaves_like "minor version is ignored"
it_behaves_like "patch version is ignored"
end
- describe "with --minor option" do
- subject { bundle "outdated --minor" }
+ describe "with --filter-minor option" do
+ subject { bundle "outdated --filter-minor" }
it_behaves_like "minor version updates are detected"
it_behaves_like "major version is ignored"
it_behaves_like "patch version is ignored"
end
- describe "with --patch option" do
- subject { bundle "outdated --patch" }
+ describe "with --filter-patch option" do
+ subject { bundle "outdated --filter-patch" }
it_behaves_like "patch version updates are detected"
it_behaves_like "major version is ignored"
it_behaves_like "minor version is ignored"
end
- describe "with --minor --patch options" do
- subject { bundle "outdated --minor --patch" }
+ describe "with --filter-minor --filter-patch options" do
+ subject { bundle "outdated --filter-minor --filter-patch" }
it_behaves_like "minor version updates are detected"
it_behaves_like "patch version updates are detected"
it_behaves_like "major version is ignored"
end
- describe "with --major --minor options" do
- subject { bundle "outdated --major --minor" }
+ describe "with --filter-major --filter-minor options" do
+ subject { bundle "outdated --filter-major --filter-minor" }
it_behaves_like "major version updates are detected"
it_behaves_like "minor version updates are detected"
it_behaves_like "patch version is ignored"
end
- describe "with --major --patch options" do
- subject { bundle "outdated --major --patch" }
+ describe "with --filter-major --filter-patch options" do
+ subject { bundle "outdated --filter-major --filter-patch" }
it_behaves_like "major version updates are detected"
it_behaves_like "patch version updates are detected"
it_behaves_like "minor version is ignored"
end
- describe "with --major --minor --patch options" do
- subject { bundle "outdated --major --minor --patch" }
+ describe "with --filter-major --filter-minor --filter-patch options" do
+ subject { bundle "outdated --filter-major --filter-minor --filter-patch" }
it_behaves_like "major version updates are detected"
it_behaves_like "minor version updates are detected"
it_behaves_like "patch version updates are detected"
end
+
+ context "conservative updates" do
+ context "without update-strict" do
+ before do
+ build_repo4 do
+ build_gem "patch", %w(1.0.0 1.0.1)
+ build_gem "minor", %w(1.0.0 1.0.1 1.1.0)
+ build_gem "major", %w(1.0.0 1.0.1 1.1.0 2.0.0)
+ end
+
+ # establish a lockfile set to 1.0.0
+ install_gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem 'patch', '1.0.0'
+ gem 'minor', '1.0.0'
+ gem 'major', '1.0.0'
+ G
+
+ # remove 1.4.3 requirement and bar altogether
+ # to setup update specs below
+ gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem 'patch'
+ gem 'minor'
+ gem 'major'
+ G
+ end
+
+ it "shows nothing when patching and filtering to minor" do
+ bundle "outdated --patch --filter-minor"
+
+ expect(out).to include("Bundle up to date!") # it shouldn't say this, but will get back to this with: #5076
+ expect(out).not_to include("patch (newest")
+ expect(out).not_to include("minor (newest")
+ expect(out).not_to include("major (newest")
+ end
+
+ it "shows all gems when patching and filtering to patch" do
+ bundle "outdated --patch --filter-patch"
+
+ expect(out).to include("patch (newest")
+ expect(out).to include("minor (newest")
+ expect(out).to include("major (newest")
+ end
+
+ it "shows minor and major when updating to minor and filtering to patch and minor" do
+ bundle "outdated --minor --filter-minor"
+
+ expect(out).not_to include("patch (newest")
+ expect(out).to include("minor (newest")
+ expect(out).to include("major (newest")
+ end
+
+ it "shows minor when updating to major and filtering to minor with parseable" do
+ bundle "outdated --major --filter-minor --parseable"
+
+ expect(out).not_to include("patch (newest")
+ expect(out).to include("minor (newest")
+ expect(out).not_to include("major (newest")
+ end
+ end
+
+ context "with update-strict" do
+ before do
+ build_repo4 do
+ build_gem "foo", %w(1.4.3 1.4.4) do |s|
+ s.add_dependency "bar", "~> 2.0"
+ end
+ build_gem "foo", %w(1.4.5 1.5.0) do |s|
+ s.add_dependency "bar", "~> 2.1"
+ end
+ build_gem "foo", %w(1.5.1) do |s|
+ s.add_dependency "bar", "~> 3.0"
+ end
+ build_gem "bar", %w(2.0.3 2.0.4 2.0.5 2.1.0 2.1.1 3.0.0)
+ build_gem "qux", %w(1.0.0 1.1.0 2.0.0)
+ end
+
+ # establish a lockfile set to 1.4.3
+ install_gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem 'foo', '1.4.3'
+ gem 'bar', '2.0.3'
+ gem 'qux', '1.0.0'
+ G
+
+ # remove 1.4.3 requirement and bar altogether
+ # to setup update specs below
+ gemfile <<-G
+ source "file://#{gem_repo4}"
+ gem 'foo'
+ gem 'qux'
+ G
+ end
+
+ it "shows gems with update-strict updating to patch and filtering to patch" do
+ bundle "outdated --patch --update-strict --filter-patch"
+
+ expect(out).to include("foo (newest 1.4.4")
+ expect(out).to include("bar (newest 2.0.5")
+ expect(out).not_to include("qux (newest")
+ end
+ end
+ end
end