# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::ErrorTracking::StackTraceHighlightDecorator do
let(:error_event) { build(:error_tracking_error_event) }
describe '.decorate' do
subject(:decorate) { described_class.decorate(error_event) }
it 'does not change issue_id' do
expect(decorate.issue_id).to eq(error_event.issue_id)
end
it 'does not change date_received' do
expect(decorate.date_received).to eq(error_event.date_received)
end
it 'decorates the stack trace context' do
expect(decorate.stack_trace_entries).to eq(
[
{
'function' => 'puts',
'lineNo' => 14,
'filename' => 'hello_world.rb',
'context' => [
[10, '# Ruby example'],
[11, 'class HelloWorld'],
[12, ' def self.message'],
[13, ' @name = \'World\''],
[14, %Q[ puts "Hello \#{@name}"]],
[15, ' end'],
[16, 'end']
]
},
{
'function' => 'print',
'lineNo' => 6,
'filename' => 'HelloWorld.swift',
'context' => [
[1, '// Swift example'],
[2, 'struct HelloWorld {'],
[3, ' let name = "World"'],
[4, ''],
[5, ' static func message() {'],
[6, ' print("Hello, \\(self.name)")'],
[7, ' }'],
[8, '}']
]
},
{
'function' => 'print',
'lineNo' => 3,
'filename' => 'hello_world.php',
'context' => [
[1, '// PHP/Hack example'],
[2, '<?php'],
[3, 'echo \'Hello, World!\';']
]
},
{
'filename' => 'blank.txt'
}
]
)
end
end
end