Skip to content

Commit

Permalink
Initialize failure line groups as array. Issue #56
Browse files Browse the repository at this point in the history
  • Loading branch information
numbata authored and mcmire committed Jan 29, 2020
1 parent 0d6fff7 commit aca3398
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/super_diff/rspec/monkey_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ def initialize(exception, example, options={})
@skip_shared_group_trace = options.fetch(:skip_shared_group_trace, false)
# Patch to convert options[:failure_lines] to groups
if options.include?(:failure_lines)
@failure_line_groups = {
lines: options[:failure_lines],
already_colorized: false
}
@failure_line_groups = [
{
lines: options[:failure_lines],
already_colorized: false
}
]
end
end

Expand Down
21 changes: 21 additions & 0 deletions spec/integration/rspec/unhandled_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,25 @@
end
end
end

context "when multiple exception occur" do
it "highlights the first line in red, and then leaves the rest of the message alone" do
as_both_colored_and_uncolored do |color_enabled|
program = <<~PROGRAM.strip
#{set_up_with("super_diff/rspec", color_enabled: color_enabled)}
RSpec.describe "test" do
after(:each) do
raise "Some kind of after error or whatever\\n\\nThis is another line"
end
it "passes" do
raise "Some kind of error or whatever\\n\\nThis is another line"
end
end
PROGRAM

expect(program).
to produce_output_when_run('Some kind of after error or whatever')
end
end
end
end

0 comments on commit aca3398

Please sign in to comment.