From 35c31dc8b0cf3b1969c2106f2e85ddb0df679009 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 31 Jul 2023 19:25:47 +0900 Subject: [PATCH] Suppress aborting message from tests `Kernel#abort` prints the message first, then raises. --- spec/lrama/command_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/lrama/command_spec.rb b/spec/lrama/command_spec.rb index 3a63aae6..70f64abb 100644 --- a/spec/lrama/command_spec.rb +++ b/spec/lrama/command_spec.rb @@ -21,8 +21,10 @@ describe "a grammar file isn't specified" do it "returns stderr" do command = Lrama::Command.new([]) + message = "File should be specified\n" + allow(STDERR).to receive(:write).with(message) expect{ command.run }.to raise_error(SystemExit) do |e| - expect(e.message).to eq("File should be specified\n") + expect(e.message).to eq(message) end end end @@ -30,8 +32,10 @@ describe "STDIN mode, but a grammar file isn't specified" do it "returns stderr" do command = Lrama::Command.new(["-"]) + message = "File name for STDIN should be specified\n" + allow(STDERR).to receive(:write).with(message) expect{ command.run }.to raise_error(SystemExit) do |e| - expect(e.message).to eq("File name for STDIN should be specified\n") + expect(e.message).to eq(message) end end end