From 3c7bfbc4378eec89cae1a7859cda531937ed2d05 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 6 Jun 2022 11:50:57 +0200 Subject: [PATCH] Verify error messages --- spec/test_hook_spec.rb | 4 +++- spec/test_spec.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/test_hook_spec.rb b/spec/test_hook_spec.rb index 5d647a2..236279d 100644 --- a/spec/test_hook_spec.rb +++ b/spec/test_hook_spec.rb @@ -15,7 +15,9 @@ describe 'Test Hook' do end it 'fails with a #fail line' do - expect { run '#fail' }.to raise_error + expect { run '#fail' }.to raise_error(RuntimeError) { |error| + expect(error.message).to eq('Cannot run test_hook.rb') + } end def run(input) diff --git a/spec/test_spec.rb b/spec/test_spec.rb index 6951a2a..ce53719 100644 --- a/spec/test_spec.rb +++ b/spec/test_spec.rb @@ -123,7 +123,9 @@ describe FormatStaged do it 'fails if the hook returns a nonzero status' do repo.set_content 'test.test', '#fail' repo.stage 'test.test' - expect { repo.run_formatter }.to raise_error + expect { repo.run_formatter }.to raise_error(RuntimeError) { |error| + expect(error.message).to eq 'Error formatting test.test' + } end it 'leaves files alone when write is false' do