Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize failure line groups as array. Issue #56 #66

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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