Skip to content
Draft
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
12 changes: 8 additions & 4 deletions lib/rspec/github/notification_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(notification)
end

def line
example.location.split(':')[1]
location[1]
end

def annotation
Expand All @@ -25,7 +25,7 @@ def annotation

def path
# TODO: use `delete_prefix` when dropping ruby 2.4 support
File.realpath(raw_path).sub(/\A#{workspace}#{File::SEPARATOR}/, '')
File.realpath(location[0]).sub(/\A#{workspace}#{File::SEPARATOR}/, '')
end

private
Expand All @@ -42,8 +42,12 @@ def message
end
end

def raw_path
example.location.split(':')[0]
def location
if @notification.respond_to?(:exception)
@notification.exception.backtrace.first.split(':')
else
example.location.split(':')
end
end

def workspace
Expand Down
9 changes: 9 additions & 0 deletions spec/integration/crashing_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require_relative './test_class.rb'

RSpec.describe RSpec::Github::Formatter do
it 'creates an error annotation for crashing specs' do
expect(TestClass.crash).to eq true
end
end
5 changes: 5 additions & 0 deletions spec/integration/test_class.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class TestClass
def self.crash
raise 'Ay!'
end
end