Skip to content

Commit aca3398

Browse files
numbatamcmire
authored andcommitted
Initialize failure line groups as array. Issue #56
1 parent 0d6fff7 commit aca3398

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

lib/super_diff/rspec/monkey_patches.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,12 @@ def initialize(exception, example, options={})
9191
@skip_shared_group_trace = options.fetch(:skip_shared_group_trace, false)
9292
# Patch to convert options[:failure_lines] to groups
9393
if options.include?(:failure_lines)
94-
@failure_line_groups = {
95-
lines: options[:failure_lines],
96-
already_colorized: false
97-
}
94+
@failure_line_groups = [
95+
{
96+
lines: options[:failure_lines],
97+
already_colorized: false
98+
}
99+
]
98100
end
99101
end
100102

spec/integration/rspec/unhandled_errors_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,25 @@
6666
end
6767
end
6868
end
69+
70+
context "when multiple exception occur" do
71+
it "highlights the first line in red, and then leaves the rest of the message alone" do
72+
as_both_colored_and_uncolored do |color_enabled|
73+
program = <<~PROGRAM.strip
74+
#{set_up_with("super_diff/rspec", color_enabled: color_enabled)}
75+
RSpec.describe "test" do
76+
after(:each) do
77+
raise "Some kind of after error or whatever\\n\\nThis is another line"
78+
end
79+
it "passes" do
80+
raise "Some kind of error or whatever\\n\\nThis is another line"
81+
end
82+
end
83+
PROGRAM
84+
85+
expect(program).
86+
to produce_output_when_run('Some kind of after error or whatever')
87+
end
88+
end
89+
end
6990
end

0 commit comments

Comments
 (0)