summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--DEVELOPMENT.md18
-rw-r--r--lib/bundler/cli/outdated.rb31
-rw-r--r--spec/commands/outdated_spec.rb114
3 files changed, 109 insertions, 54 deletions
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
index 464dfec317..0061fe6d80 100644
--- a/DEVELOPMENT.md
+++ b/DEVELOPMENT.md
@@ -33,6 +33,24 @@ Bundler doesn't use a Gemfile to list development dependencies, because when we
With that set up, you can test changes you've made to Bundler by running `dbundle`, without interfering with the regular `bundle` command.
+# Submitting Pull Requests
+
+Before you submit a pull request, please remember to do the following:
+
+- Make sure the code formatting and styling adheres to the guidelines. We use Rubocop for this. Lack of formatting adherence will result in automatic Travis build failures.
+
+ $ bin/rubocop -a
+
+- Please run the test suite:
+
+ $ bin/rspec
+
+- If you are unable to run the entire test suite, please run the unit test suite and at least the integration specs related to the command or domain of Bundler that your code changes relate to.
+
+- Ex. For a pull request that changes something with `bundle update`, you might run:
+
+ $ bin/rspec spec/bundler
+ $ bin/rspec spec/commands/update_spec.rb
# Bug triage
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 1535b2c4bf..d0ae0b46c5 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -56,18 +56,12 @@ module Bundler
end
active_spec = active_spec.last
- if options[:major]
- current_major = current_spec.version.segments.first
- active_major = active_spec.version.segments.first
- active_spec = nil unless active_major > current_major
- end
-
- if options[:minor]
- current_minor = current_spec.version.segments[0, 2].compact.join(".")
- active_minor = active_spec.version.segments[0, 2].compact.join(".")
- active_spec = nil unless active_minor > current_minor
+ if options[:major] || options[:minor]
+ update_present = update_present_via_semver_portions(current_spec, active_spec, options)
+ active_spec = nil unless update_present
end
end
+
next if active_spec.nil?
gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
@@ -123,5 +117,22 @@ module Bundler
raise ProductionError, error_message
end
end
+
+ def update_present_via_semver_portions(current_spec, active_spec, options)
+ current_major = current_spec.version.segments.first
+ active_major = active_spec.version.segments.first
+
+ update_present = false
+
+ update_present = active_major > current_major if options[:major]
+
+ if options[:minor] && current_major == active_major
+ current_minor = current_spec.version.segments[1, 1].first
+ active_minor = active_spec.version.segments[1, 1].first
+ update_present = active_minor > current_minor
+ end
+
+ update_present
+ end
end
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index b4895659db..65da3f6ea1 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -219,80 +219,106 @@ describe "bundle outdated" do
expect(out).to include("Installing foo 1.0")
end
- describe "with --major option" do
- it "only reports gems that have a newer major version" do
- update_repo2 do
- build_gem "weakling", "0.2.0"
- build_gem "activesupport", "3.0"
- end
+ context "after bundle install --deployment" do
+ before do
+ install_gemfile <<-G, :deployment => true
+ source "file://#{gem_repo2}"
- bundle "outdated --major"
- expect(out).to_not include("weakling (newest")
- expect(out).to include("activesupport (newest")
+ gem "rack"
+ gem "foo"
+ G
+ end
+
+ it "outputs a helpful message about being in deployment mode" do
+ update_repo2 { build_gem "activesupport", "3.0" }
+
+ bundle "outdated"
+ expect(exitstatus).to_not be_zero if exitstatus
+ expect(out).to include("You are trying to check outdated gems in deployment mode.")
+ expect(out).to include("Run `bundle outdated` elsewhere.")
+ expect(out).to include("If this is a development machine, remove the ")
+ expect(out).to include("Gemfile freeze\nby running `bundle install --no-deployment`.")
end
+ end
- it "ignore gems not in semantic version" do
+ shared_examples_for "major version is ignored" do
+ before do
update_repo2 do
- build_gem "weakling", "1"
+ build_gem "activesupport", "3.3.5"
+ build_gem "weakling", "1.0.1"
end
+ end
- bundle "outdated --major"
- expect(out).to include("weakling (newest")
+ it "ignores gems that have updates in the major version" do
+ subject
+ expect(out).to_not include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
end
end
- describe "with --minor option" do
- it "only reports gems that have at least a newer minor version" do
+ shared_examples_for "minor version is ignored" do
+ before do
update_repo2 do
- build_gem "activesupport", "3.0.0"
- build_gem "weakling", "0.2.0"
+ build_gem "activesupport", "2.4.5"
+ build_gem "weakling", "0.3.1"
end
+ end
- bundle "outdated --minor"
- expect(out).to include("weakling (newest")
- expect(out).to include("activesupport (newest")
+ it "ignores gems that have updates in the minor version" do
+ subject
+ expect(out).to_not include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
end
+ end
- it "ignore patch version" do
+ shared_examples_for "patch version is ignored" do
+ before do
update_repo2 do
build_gem "activesupport", "2.3.6"
build_gem "weakling", "0.0.4"
end
+ end
- bundle "outdated --minor"
- expect(out).to_not include("weakling (newest")
+ it "ignores gems that have updates in the patch version" do
+ subject
expect(out).to_not include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
end
+ end
+
+ describe "with --major option" do
+ subject { bundle "outdated --major" }
- it "ignore gems not in semantic version" do
+ it "only reports gems that have a newer major version" do
update_repo2 do
- build_gem "weakling", "1"
+ build_gem "activesupport", "3.3.5"
+ build_gem "weakling", "0.8.0"
end
- bundle "outdated --minor"
- expect(out).to include("weakling (newest")
+ subject
+ expect(out).to include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
end
- end
- context "after bundle install --deployment" do
- before do
- install_gemfile <<-G, :deployment => true
- source "file://#{gem_repo2}"
+ it_behaves_like "minor version is ignored"
+ it_behaves_like "patch version is ignored"
+ end
- gem "rack"
- gem "foo"
- G
- end
+ describe "with --minor option" do
+ subject { bundle "outdated --minor" }
- it "outputs a helpful message about being in deployment mode" do
- update_repo2 { build_gem "activesupport", "3.0" }
+ it "only reports gems that have a newer minor version" do
+ update_repo2 do
+ build_gem "activesupport", "2.7.5"
+ build_gem "weakling", "2.0.1"
+ end
- bundle "outdated"
- expect(exitstatus).to_not be_zero if exitstatus
- expect(out).to include("You are trying to check outdated gems in deployment mode.")
- expect(out).to include("Run `bundle outdated` elsewhere.")
- expect(out).to include("If this is a development machine, remove the ")
- expect(out).to include("Gemfile freeze\nby running `bundle install --no-deployment`.")
+ subject
+ expect(out).to include("activesupport (newest")
+ expect(out).to_not include("weakling (newest")
end
+
+ it_behaves_like "major version is ignored"
+ it_behaves_like "patch version is ignored"
end
end