diff options
Diffstat (limited to 'spec/bundler/commands/exec_spec.rb')
-rw-r--r-- | spec/bundler/commands/exec_spec.rb | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 76841dcff6..6835305d55 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -570,7 +570,22 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable is empty" do + context "the executable is empty", :bundler => "< 2" do + let(:executable) { "" } + + let(:exit_code) { 0 } + let(:expected) { "#{path} is empty" } + let(:expected_err) { "" } + if LessThanProc.with(RUBY_VERSION).call("1.9") + # Kernel#exec in ruby < 1.9 will raise Errno::ENOEXEC if the command content is empty, + # even if the command is set as an executable. + pending "Kernel#exec is different" + else + it_behaves_like "it runs" + end + end + + context "the executable is empty", :bundler => "2" do let(:executable) { "" } let(:exit_code) { 0 } @@ -579,7 +594,18 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable raises" do + context "the executable raises", :bundler => "< 2" do + let(:executable) { super() << "\nraise 'ERROR'" } + let(:exit_code) { 1 } + let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } + let(:expected_err) do + "RuntimeError: ERROR\n #{path}:10" + + (Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'") + end + it_behaves_like "it runs" + end + + context "the executable raises", :bundler => "2" do let(:executable) { super() << "\nraise 'ERROR'" } let(:exit_code) { 1 } let(:expected_err) do @@ -589,7 +615,16 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "the executable raises an error without a backtrace" do + context "the executable raises an error without a backtrace", :bundler => "< 2" do + let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } + let(:exit_code) { 1 } + let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" } + let(:expected_err) { "Err: Err" } + + it_behaves_like "it runs" + end + + context "the executable raises an error without a backtrace", :bundler => "2" do let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } let(:exit_code) { 1 } let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" } @@ -603,7 +638,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "when Bundler.setup fails", :bundler => "< 3" do + context "when Bundler.setup fails", :bundler => "< 2" do before do gemfile <<-G gem 'rack', '2' @@ -620,7 +655,7 @@ RSpec.describe "bundle exec" do it_behaves_like "it runs" end - context "when Bundler.setup fails", :bundler => "3" do + context "when Bundler.setup fails", :bundler => "2" do before do gemfile <<-G gem 'rack', '2' |