From 885ed215c21575bcb264038543c9834bb4a98744 Mon Sep 17 00:00:00 2001 From: Terence Lee Date: Thu, 27 Dec 2012 22:47:00 -0500 Subject: handle the case where the binstub already exists, also --force --- spec/other/binstubs_spec.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'spec/other') diff --git a/spec/other/binstubs_spec.rb b/spec/other/binstubs_spec.rb index faab6c0a..2a14241f 100644 --- a/spec/other/binstubs_spec.rb +++ b/spec/other/binstubs_spec.rb @@ -92,4 +92,43 @@ describe "bundle binstubs " do expect(bundled_app("exec/rails")).to exist end end + + context "when the bin already exists" do + it "don't override it and warn" do + FileUtils.mkdir_p(bundled_app("bin")) + File.open(bundled_app("bin/rackup"), 'wb') do |file| + file.print "OMG" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "binstubs rack" + + expect(bundled_app("bin/rackup")).to exist + expect(File.read(bundled_app("bin/rackup"))).to eq("OMG") + expect(out).to eq("Skipping rackup, since it already exists.") + end + + context "when using --force" do + it "overrides the binstub" do + FileUtils.mkdir_p(bundled_app("bin")) + File.open(bundled_app("bin/rackup"), 'wb') do |file| + file.print "OMG" + end + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "binstubs rack --force" + + expect(bundled_app("bin/rackup")).to exist + expect(File.read(bundled_app("bin/rackup"))).not_to eq("OMG") + end + end + end end -- cgit v1.2.3