debian-mirror-gitlab/spec/lib/gitlab/utils/error_message_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
733 B
Ruby
Raw Permalink Normal View History

2023-05-27 22:25:52 +05:30
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Utils::ErrorMessage, feature_category: :error_tracking do
let(:klass) do
Class.new do
include Gitlab::Utils::ErrorMessage
end
end
2023-06-20 00:43:36 +05:30
let(:message) { 'Something went wrong' }
2023-05-27 22:25:52 +05:30
2023-06-20 00:43:36 +05:30
subject(:object) { klass.new }
2023-05-27 22:25:52 +05:30
2023-06-20 00:43:36 +05:30
describe '#to_user_facing' do
it 'returns a user-facing error message with the UF prefix' do
2023-07-09 08:55:56 +05:30
expect(described_class.to_user_facing(message)).to eq("UF #{message}")
2023-06-20 00:43:36 +05:30
end
end
2023-05-27 22:25:52 +05:30
2023-06-20 00:43:36 +05:30
describe '#prefixed_error_message' do
it 'returns a message with the given prefix' do
prefix = 'ERROR'
2023-07-09 08:55:56 +05:30
expect(described_class.prefixed_error_message(message, prefix)).to eq("#{prefix} #{message}")
2023-05-27 22:25:52 +05:30
end
end
end