Skip to content

Commit

Permalink
repair standard error spec
Browse files Browse the repository at this point in the history
  • Loading branch information
hyuraku committed Aug 30, 2023
1 parent 8c89d57 commit d921108
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions spec/exception_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@

it "prints standard error message" do
described_class.handle_exception(output, exception, pry_instance)
expect(output.string)
.to eq("StandardError: oops\nfrom /bin/pry:23:in `<main>'\n")
end
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2')
expect(output.string)
.to include("StandardError: oops\nfrom /bin/pry:23:in `<main>'\n")
else
expect(output.string)
.to include("StandardError: oops (StandardError)\nfrom /bin/pry:23:in `<main>'\n")
end
end
end

context "when exception is a nested standard error" do
Expand All @@ -54,12 +59,21 @@

it "prints standard error message" do
described_class.handle_exception(output, exception, pry_instance)
expect(output.string).to match(
/RuntimeError:\souter\soops\n
from\s.+\n
Caused\sby\sRuntimeError:\snested\soops\n
from.+/x
)
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2')
expect(output.string).to match(
/RuntimeError:\souter\soops\n
from\s.+\n
Caused\sby\sRuntimeError:\snested\soops\n
from.+/x
)
else
expect(output.string).to match(
/RuntimeError:\souter\soops\s\(RuntimeError\)\n
from\s.+\n
Caused\sby\sRuntimeError:\snested\soops\n
from\s.+/x
)
end
end
end
end
Expand Down

0 comments on commit d921108

Please sign in to comment.