Skip to content

Commit

Permalink
Fix support for RSpec < 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncodes committed Oct 18, 2019
1 parent ba98856 commit c752732
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/rspec_junit_formatter/rspec3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,23 @@ def failure_message_for(example)
end

def failure_for(notification)
lines = notification.fully_formatted_lines(nil, RSpec::Core::Notifications::NullColorizer).map(&:to_s)
lines = if notification.respond_to?(:fully_formatted_lines)
notification.fully_formatted_lines(nil, RSpec::Core::Notifications::NullColorizer).map(&:to_s)
else
notification.fully_formatted(nil, RSpec::Core::Notifications::NullColorizer).split("\n")
end

unless lines.first.empty?
raise 'Expected first line to be empty'
end
lines.shift

unless notification.respond_to?(:fully_formatted_lines)
if lines[0][2] = ')'
lines[0][2] = ' '
end
end

indentation = lines.reject(&:empty?).map { |line| line[/^[ \t]*/] }.min
lines = lines.map { |line| line.sub(/^#{Regexp.escape indentation}/, '') }

Expand Down

0 comments on commit c752732

Please sign in to comment.