summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-03-29 11:06:42 +0900
committerHomu <homu@barosl.com>2016-03-29 11:06:42 +0900
commitbe871041f01ae758f9ec2b420a511899b022a888 (patch)
tree4159a55235b152fc1ec70d36914fc5c623fcd754
parent804e47d7bec44f35178049db5bce3c25c5bc1c33 (diff)
parent2fc60267bb4e94661e63ca52291a2e74183e7160 (diff)
downloadbundler-be871041f01ae758f9ec2b420a511899b022a888.tar.gz
Auto merge of #4404 - bundler:1-12-backports, r=indirect
Backport #4393 and #4403 to 1.12 None
-rw-r--r--lib/bundler/cli/outdated.rb8
-rw-r--r--lib/bundler/runtime.rb3
-rw-r--r--spec/commands/outdated_spec.rb126
-rw-r--r--spec/commands/package_spec.rb79
4 files changed, 145 insertions, 71 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 4296ec630d..7928c1f0af 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -126,13 +126,13 @@ module Bundler
update_present = active_major > current_major if options[:major]
- if (options[:minor] || options[:patch]) && current_major == active_major
+ if !update_present && (options[:minor] || options[:patch]) && current_major == active_major
current_minor = current_spec.version.segments[1, 1].first
active_minor = active_spec.version.segments[1, 1].first
- if options[:minor]
- update_present = active_minor > current_minor
- elsif options[:patch] && current_minor == active_minor
+ update_present = active_minor > current_minor if options[:minor]
+
+ if !update_present && options[:patch] && current_minor == active_minor
current_patch = current_spec.version.segments[2, 1].first
active_patch = active_spec.version.segments[2, 1].first
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index e80a9eaeba..d4a7837072 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -133,9 +133,10 @@ module Bundler
gemspec = gemspec_cache_hash.values.first
root_gem_name = gemspec.name unless gemspec.nil?
end
+
specs.each do |spec|
next if spec.name == "bundler"
- next if File.exist?("#{root_gem_name}.gemspec") && spec.source.class == Bundler::Source::Path && root_gem_name && spec.name == root_gem_name
+ next if !Dir.glob("*.gemspec").empty? && spec.source.class == Bundler::Source::Path && root_gem_name && spec.name == root_gem_name
spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
end
diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb
index 8f961e5a42..7f699f035d 100644
--- a/spec/commands/outdated_spec.rb
+++ b/spec/commands/outdated_spec.rb
@@ -241,21 +241,65 @@ describe "bundle outdated" do
end
end
- shared_examples_for "major version is ignored" do
+ shared_examples_for "version update is detected" do
+ it "reports that a gem has a newer version" do
+ subject
+ expect(out).to include("activesupport (newest")
+ end
+ end
+
+ shared_examples_for "major version updates are detected" do
before do
update_repo2 do
build_gem "activesupport", "3.3.5"
- build_gem "weakling", "1.0.1"
+ build_gem "weakling", "0.8.0"
+ end
+ end
+
+ it_behaves_like "version update is detected"
+ end
+
+ shared_examples_for "minor version updates are detected" do
+ before do
+ update_repo2 do
+ build_gem "activesupport", "2.7.5"
+ build_gem "weakling", "2.0.1"
+ end
+ end
+
+ it_behaves_like "version update is detected"
+ end
+
+ shared_examples_for "patch version updates are detected" do
+ before do
+ update_repo2 do
+ build_gem "activesupport", "2.3.7"
+ build_gem "weakling", "0.3.1"
end
end
- it "ignores gems that have updates in the major version" do
+ it_behaves_like "version update is detected"
+ end
+
+ shared_examples_for "no version updates are detected" do
+ it "does not detect any version updates" do
subject
expect(out).to_not include("activesupport (newest")
expect(out).to_not include("weakling (newest")
end
end
+ shared_examples_for "major version is ignored" do
+ before do
+ update_repo2 do
+ build_gem "activesupport", "3.3.5"
+ build_gem "weakling", "1.0.1"
+ end
+ end
+
+ it_behaves_like "no version updates are detected"
+ end
+
shared_examples_for "minor version is ignored" do
before do
update_repo2 do
@@ -264,11 +308,7 @@ describe "bundle outdated" do
end
end
- 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
+ it_behaves_like "no version updates are detected"
end
shared_examples_for "patch version is ignored" do
@@ -279,27 +319,13 @@ describe "bundle outdated" do
end
end
- 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
+ it_behaves_like "no version updates are detected"
end
describe "with --major option" do
subject { bundle "outdated --major" }
- it "only reports gems that have a newer major version" do
- update_repo2 do
- build_gem "activesupport", "3.3.5"
- build_gem "weakling", "0.8.0"
- end
-
- subject
- expect(out).to include("activesupport (newest")
- expect(out).to_not include("weakling (newest")
- end
-
+ it_behaves_like "major version updates are detected"
it_behaves_like "minor version is ignored"
it_behaves_like "patch version is ignored"
end
@@ -307,17 +333,7 @@ describe "bundle outdated" do
describe "with --minor option" do
subject { bundle "outdated --minor" }
- 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
-
- subject
- expect(out).to include("activesupport (newest")
- expect(out).to_not include("weakling (newest")
- end
-
+ it_behaves_like "minor version updates are detected"
it_behaves_like "major version is ignored"
it_behaves_like "patch version is ignored"
end
@@ -325,18 +341,40 @@ describe "bundle outdated" do
describe "with --patch option" do
subject { bundle "outdated --patch" }
- it "only reports gems that have a newer patch version" do
- update_repo2 do
- build_gem "activesupport", "2.3.7"
- build_gem "weakling", "0.3.1"
- end
+ it_behaves_like "patch version updates are detected"
+ it_behaves_like "major version is ignored"
+ it_behaves_like "minor version is ignored"
+ end
- subject
- expect(out).to include("activesupport (newest")
- expect(out).to_not include("weakling (newest")
- end
+ describe "with --minor --patch options" do
+ subject { bundle "outdated --minor --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" }
+
+ 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" }
+
+ 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" }
+
+ 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
end
diff --git a/spec/commands/package_spec.rb b/spec/commands/package_spec.rb
index 08b36b1e9d..8cf6de4c8c 100644
--- a/spec/commands/package_spec.rb
+++ b/spec/commands/package_spec.rb
@@ -31,33 +31,68 @@ describe "bundle package" do
expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
end
end
+
context "with a gemspec" do
- before do
- File.open(bundled_app("mygem.gemspec"), "w") do |f|
- f.write <<-G
- Gem::Specification.new do |s|
- s.name = "mygem"
- s.version = "0.1.1"
- s.summary = ""
- s.authors = ["gem author"]
- s.add_development_dependency "nokogiri", "=1.4.2"
- end
- G
+ context "that has the same name as the gem" do
+ before do
+ File.open(bundled_app("mygem.gemspec"), "w") do |f|
+ f.write <<-G
+ Gem::Specification.new do |s|
+ s.name = "mygem"
+ s.version = "0.1.1"
+ s.summary = ""
+ s.authors = ["gem author"]
+ s.add_development_dependency "nokogiri", "=1.4.2"
+ end
+ G
+ end
+ end
+
+ it "caches all dependencies except bundler and the gemspec specified gem" do
+ gemfile <<-D
+ source "file://#{gem_repo1}"
+ gem 'rack'
+ gemspec
+ D
+
+ bundle! "package --all"
+
+ expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
+ expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
+ expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
+ expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
end
end
- it "caches all dependencies except bundler and the gemspec specified gem" do
- gemfile <<-D
- source "file://#{gem_repo1}"
- gem 'rack'
- gemspec
- D
- bundle! "package --all"
+ context "that has a different name as the gem" do
+ before do
+ File.open(bundled_app("mygem_diffname.gemspec"), "w") do |f|
+ f.write <<-G
+ Gem::Specification.new do |s|
+ s.name = "mygem"
+ s.version = "0.1.1"
+ s.summary = ""
+ s.authors = ["gem author"]
+ s.add_development_dependency "nokogiri", "=1.4.2"
+ end
+ G
+ end
+ end
- expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
- expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
- expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
- expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
+ it "caches all dependencies except bundler and the gemspec specified gem" do
+ gemfile <<-D
+ source "file://#{gem_repo1}"
+ gem 'rack'
+ gemspec
+ D
+
+ bundle! "package --all"
+
+ expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist
+ expect(bundled_app("vendor/cache/nokogiri-1.4.2.gem")).to exist
+ expect(bundled_app("vendor/cache/mygem-0.1.1.gem")).to_not exist
+ expect(bundled_app("vendor/cache/bundler-0.9.gem")).to_not exist
+ end
end
end
end