summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2018-09-18 20:07:06 -0300
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2018-09-18 21:40:42 -0300
commit90109e4efd2ba96967a2f2a8326c6f82d4e67297 (patch)
treec7cd85c73cedc1cde1611aceb35f59820ae6a41e
parent07965169a1eb40bfd202767ccc05c19ad8875527 (diff)
downloadbundler-90109e4efd2ba96967a2f2a8326c6f82d4e67297.tar.gz
Convert redownload/force specs to shared specs
-rw-r--r--spec/install/redownload_spec.rb86
1 files changed, 47 insertions, 39 deletions
diff --git a/spec/install/redownload_spec.rb b/spec/install/redownload_spec.rb
index 52fa4f0d61..626a4a8e9f 100644
--- a/spec/install/redownload_spec.rb
+++ b/spec/install/redownload_spec.rb
@@ -1,62 +1,70 @@
# frozen_string_literal: true
RSpec.describe "bundle install" do
- %w[force redownload].each do |flag|
- describe_opts = {}
- describe_opts[:bundler] = "< 2" if flag == "force"
- describe "with --#{flag}", describe_opts do
- before :each do
+ before :each do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ end
+
+ shared_examples_for "an option to force redownloading gems" do
+ it "re-installs installed gems" do
+ rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
+
+ bundle! :install
+ rack_lib.open("w") {|f| f.write("blah blah blah") }
+ bundle! :install, flag => true
+
+ expect(out).to include "Installing rack 1.0.0"
+ expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ it "works on first bundle install" do
+ bundle! :install, flag => true
+
+ expect(out).to include "Installing rack 1.0.0"
+ expect(the_bundle).to include_gems "rack 1.0.0"
+ end
+
+ context "with a git gem" do
+ let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) }
+
+ before do
gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rack"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
G
end
it "re-installs installed gems" do
- rack_lib = default_bundle_path("gems/rack-1.0.0/lib/rack.rb")
+ foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb")
bundle! :install
- rack_lib.open("w") {|f| f.write("blah blah blah") }
+ foo_lib.open("w") {|f| f.write("blah blah blah") }
bundle! :install, flag => true
- expect(out).to include "Installing rack 1.0.0"
- expect(rack_lib.open(&:read)).to eq("RACK = '1.0.0'\n")
- expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
+ expect(the_bundle).to include_gems "foo 1.0"
end
it "works on first bundle install" do
bundle! :install, flag => true
- expect(out).to include "Installing rack 1.0.0"
- expect(the_bundle).to include_gems "rack 1.0.0"
+ expect(the_bundle).to include_gems "foo 1.0"
end
+ end
+ end
- context "with a git gem" do
- let!(:ref) { build_git("foo", "1.0").ref_for("HEAD", 11) }
-
- before do
- gemfile <<-G
- gem "foo", :git => "#{lib_path("foo-1.0")}"
- G
- end
-
- it "re-installs installed gems" do
- foo_lib = default_bundle_path("bundler/gems/foo-1.0-#{ref}/lib/foo.rb")
-
- bundle! :install
- foo_lib.open("w") {|f| f.write("blah blah blah") }
- bundle! :install, flag => true
-
- expect(foo_lib.open(&:read)).to eq("FOO = '1.0'\n")
- expect(the_bundle).to include_gems "foo 1.0"
- end
-
- it "works on first bundle install" do
- bundle! :install, flag => true
+ describe "with --force" do
+ it_behaves_like "an option to force redownloading gems" do
+ let(:flag) { "force" }
+ end
+ end
- expect(the_bundle).to include_gems "foo 1.0"
- end
- end
+ describe "with --redownload" do
+ it_behaves_like "an option to force redownloading gems" do
+ let(:flag) { "redownload" }
end
end
end