Class: RSpec::Github::NotificationDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/github/notification_decorator.rb

Constant Summary collapse

ESCAPE_MAP =
{
  '%' => '%25',
  "\n" => '%0A',
  "\r" => '%0D'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(notification) ⇒ NotificationDecorator

Returns a new instance of NotificationDecorator.



13
14
15
# File 'lib/rspec/github/notification_decorator.rb', line 13

def initialize(notification)
  @notification = notification
end

Instance Method Details

#annotationObject



21
22
23
24
# File 'lib/rspec/github/notification_decorator.rb', line 21

def annotation
  "#{example.full_description}\n\n#{message}"
    .gsub(Regexp.union(ESCAPE_MAP.keys), ESCAPE_MAP)
end

#lineObject



17
18
19
# File 'lib/rspec/github/notification_decorator.rb', line 17

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

#pathObject



26
27
28
29
# File 'lib/rspec/github/notification_decorator.rb', line 26

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