Skip to content

Commit

Permalink
Make SuperDiff respect extra_failure_lines metadata of RSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
willnet committed Aug 14, 2023
1 parent 7772aa1 commit 8ea7452
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/super_diff/rspec/monkey_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ def failure_line_groups
}
end
end

@failure_line_groups << {
lines: extra_failure_lines,
already_colorized: true
}
@failure_line_groups
end
end
Expand Down
21 changes: 21 additions & 0 deletions spec/integration/rspec/metadata_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require "spec_helper"

RSpec.describe "Integration with RSpec metadata for extra failure lines",
type: :integration do
it "displays extra_failure_lines of metadata" do
as_both_colored_and_uncolored do |color_enabled|
program =
make_plain_test_program(<<~TEST, color_enabled: color_enabled, preserve_as_whole_file: true)
RSpec.describe "test" do
it { expect(true).to be(false) }
after do
RSpec.current_example.metadata[:extra_failure_lines] = "foo\nbar"
end
end
TEST

expect(program).to produce_output_when_run("foo\nbar").in_color(color_enabled)
end
end
end

0 comments on commit 8ea7452

Please sign in to comment.