spec/cli_spec.rb in bundler-audit-0.6.1 vs spec/cli_spec.rb in bundler-audit-0.7.0

- old
+ new

@@ -44,9 +44,36 @@ expect(error.status).to eq(1) end end end + + context "when git is not installed" do + before do + expect(Bundler::Audit::Database).to receive(:update!).and_return(nil) + expect(Bundler).to receive(:git_present?).and_return(false) + end + + it "prints failure message" do + expect do + begin + subject.update + rescue SystemExit + end + end.to output(/Git is not installed!/).to_stdout + end + + it "exits with error status code" do + expect { + # Capture output of `update` only to keep spec output clean. + # The test regarding specific output is above. + expect { subject.update }.to output.to_stdout + }.to raise_error(SystemExit) do |error| + expect(error.success?).to eq(false) + expect(error.status).to eq(1) + end + end + end end context "--quiet" do before do allow(subject).to receive(:options).and_return(double("Options", quiet?: true))