From 8d8471951a96332209b4b89a1a2bb460c34bb2c1 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 6 Jun 2022 11:30:55 +0200 Subject: [PATCH] Add fail mode to test_hook.rb --- spec/test_hook.rb | 1 + spec/test_hook_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/spec/test_hook.rb b/spec/test_hook.rb index 380c9c7..595050e 100755 --- a/spec/test_hook.rb +++ b/spec/test_hook.rb @@ -4,6 +4,7 @@ output = [] $stdin.readlines.each do |line| exit 0 if line.chomp == '#clear' + exit 1 if line.chomp == '#fail' output << line.gsub(/([^\s]*)\s*=\s*(.*)/, '\1 = \2') end diff --git a/spec/test_hook_spec.rb b/spec/test_hook_spec.rb index a17c07b..5d647a2 100644 --- a/spec/test_hook_spec.rb +++ b/spec/test_hook_spec.rb @@ -14,6 +14,10 @@ describe 'Test Hook' do expect(out).to eq '' end + it 'fails with a #fail line' do + expect { run '#fail' }.to raise_error + end + def run(input) result = IO.popen ['ruby', "#{__dir__}/test_hook.rb"], mode: File::RDWR do |io| io.write input