From 26c5a5ff61bfe77e3bb3da27eb824bf90b138757 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Wed, 15 Apr 2015 09:39:30 -0400 Subject: [PATCH] updated the tests, exceptions are raised from the invoke_bundler! Fixes #2731 --- spec/lib/logstash/bundler_spec.rb | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/spec/lib/logstash/bundler_spec.rb b/spec/lib/logstash/bundler_spec.rb index 8c2865a4f3d..f8477563cf1 100644 --- a/spec/lib/logstash/bundler_spec.rb +++ b/spec/lib/logstash/bundler_spec.rb @@ -57,20 +57,22 @@ subject end - it 'should abort if a gem is conflicting' do - allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::VersionConflict.new('conflict') } - expect(subject.last).to be_a_kind_of(::Bundler::VersionConflict) - end - - it 'should abort if the gem is not found' do - allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::GemNotFound.new('conflict') } - expect(subject.last).to be_a_kind_of(::Bundler::GemNotFound) - end + context 'abort with an exception' do + it 'gem conflict' do + allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::VersionConflict.new('conflict') } + expect { subject }.to raise_error(::Bundler::VersionConflict) + end + + it 'gem is not found' do + allow(::Bundler::CLI).to receive(:start).with(bundler_args) { raise ::Bundler::GemNotFound.new('conflict') } + expect { subject }.to raise_error(::Bundler::GemNotFound) + end - it 'should retry until hitting :max_tries on any other error' do - options.merge!({ :max_tries => 2 }) - expect(::Bundler::CLI).to receive(:start).with(bundler_args).at_most(options[:max_tries] + 1) { raise RuntimeError } - subject + it 'on max retries' do + options.merge!({ :max_tries => 2 }) + expect(::Bundler::CLI).to receive(:start).with(bundler_args).at_most(options[:max_tries] + 1) { raise RuntimeError } + expect { subject }.to raise_error(RuntimeError) + end end end