Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
Handle false failure due to Ruby 3.4 printing module name
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Jul 14, 2024
1 parent 874223b commit 1fb220e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions spec/rspec/core/formatters/base_text_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ def run_all_and_dump_failures
it "does not show the error class" do
group.example("example name") { expect("this").to eq("that") }
run_all_and_dump_failures
expect(formatter_output.string).not_to match(/RSpec::/m)
expect(formatter_output_without_formatter_module).not_to match(/RSpec::/m)
end
end

context "with a failed message expectation (rspec-mocks)" do
it "does not show the error class" do
group.example("example name") { expect("this").to receive("that") }
run_all_and_dump_failures
expect(formatter_output.string).not_to match(/RSpec::/m)
expect(formatter_output_without_formatter_module).not_to match(/RSpec::/m)
end
end

Expand Down Expand Up @@ -293,4 +293,10 @@ def run_all_and_dump_failures
expect(formatter_output.string).to include("\e[36m")
end
end

# Ruby 3.4 includes modules names in stack traces but two of our tests are looking for RSpec module names, remove
# this one as it is considered 'safe'
def formatter_output_without_formatter_module
formatter_output.string.tr('RSpec::ExampleGroups::RSpecCoreFormattersBaseTextFormatter::DumpFailures#','')
end
end

0 comments on commit 1fb220e

Please sign in to comment.