summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Lance <stefan@lances.net>2015-06-23 19:20:58 -0400
committerSamuel E. Giddins <segiddins@segiddins.me>2015-07-16 16:51:59 -0700
commitec2ac67a57b5c510db04e456d7936ce0036c496a (patch)
tree385c62b57daf926ade2c89f4a01ec376fbc20e9f
parent8095691b79340bcd112e0f3509692046cff23324 (diff)
downloadbundler-ec2ac67a57b5c510db04e456d7936ce0036c496a.tar.gz
Add back in bundle install --binstubs specs
- but change them so they test bundle binstubs instead
-rw-r--r--spec/runtime/executable_spec.rb145
1 files changed, 145 insertions, 0 deletions
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index aa6c4edfba..51b003c904 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -8,9 +8,154 @@ describe "Running bin/* commands" do
G
end
+ it "runs the bundled command when in the bundle" do
+ bundle "install"
+ bundle "binstubs rack"
+
+ build_gem "rack", "2.0", :to_system => true do |s|
+ s.executables = "rackup"
+ end
+
+ gembin "rackup"
+ expect(out).to eq("1.0.0")
+ end
+
+ it "allows the location of the gem stubs to be specified" do
+ bundle "install"
+ bundle "binstubs rack --path gbin"
+
+ expect(bundled_app("bin")).not_to exist
+ expect(bundled_app("gbin/rackup")).to exist
+
+ gembin bundled_app("gbin/rackup")
+ expect(out).to eq("1.0.0")
+ end
+
+ it "allows absolute paths as a specification of where to install bin stubs" do
+ bundle "install"
+ bundle "binstubs rack --path #{tmp}/bin"
+
+ gembin tmp("bin/rackup")
+ expect(out).to eq("1.0.0")
+ end
+
+ it "uses the default ruby install name when shebang is not specified" do
+ bundle "install"
+ bundle "binstubs rack"
+
+ expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG['ruby_install_name']}\n")
+ end
+
+ it "allows the name of the shebang executable to be specified" do
+ bundle "install --shebang ruby-foo"
+ bundle "binstubs rack"
+ expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env ruby-foo\n")
+ end
+
+ it "runs the bundled command when out of the bundle" do
+ bundle "install"
+ bundle "binstubs rack"
+
+ build_gem "rack", "2.0", :to_system => true do |s|
+ s.executables = "rackup"
+ end
+
+ Dir.chdir(tmp) do
+ gembin "rackup"
+ expect(out).to eq("1.0.0")
+ end
+ end
+
+ it "works with gems in path" do
+ build_lib "rack", :path => lib_path("rack") do |s|
+ s.executables = 'rackup'
+ end
+
+ gemfile <<-G
+ gem "rack", :path => "#{lib_path('rack')}"
+ G
+
+ bundle "install"
+ bundle "binstubs rack"
+
+ build_gem 'rack', '2.0', :to_system => true do |s|
+ s.executables = 'rackup'
+ end
+
+ gembin "rackup"
+ expect(out).to eq('1.0')
+ end
+
+ it "don't bundle da bundla" do
+ build_gem "bundler", Bundler::VERSION, :to_system => true do |s|
+ s.executables = "bundle"
+ end
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "bundler"
+ G
+
+ bundle "install"
+ bundle "binstubs rack"
+
+ expect(bundled_app("bin/bundle")).not_to exist
+ end
+
it "does not generate bin stubs if the option was not specified" do
bundle "install"
expect(bundled_app("bin/rackup")).not_to exist
end
+
+ it "allows you to stop installing binstubs" do
+ bundle "install"
+ bundle "binstubs rack --path bin/"
+ bundled_app("bin/rackup").rmtree
+ bundle "binstubs rack --path \"\""
+
+ expect(bundled_app("bin/rackup")).not_to exist
+ #expect(bundled_app("rackup")).not_to exist
+
+ bundle "config bin"
+ expect(out).to include("You have not configured a value for `bin`")
+ end
+
+ it "remembers that the option was specified" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ G
+
+ bundle "install"
+ bundle "binstubs rack --path bin/"
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ gem "rack"
+ G
+
+ bundle "install"
+
+ expect(bundled_app("bin/rackup")).to exist
+ end
+
+ it "rewrites bins on --binstubs (to maintain backwards compatibility)" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "install"
+ bundle "binstubs rack --path bin/"
+
+ File.open(bundled_app("bin/rackup"), 'wb') do |file|
+ file.print "OMG"
+ end
+
+ bundle "install"
+
+ expect(bundled_app("bin/rackup").read).to_not eq("OMG")
+ end
end