Welcome to mirror list, hosted at ThFree Co, Russian Federation.

filename_length_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a5bdce9a3397ec1895a4b9c0add114403cc7c5dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'rubocop_spec_helper'
require_relative '../../../rubocop/cop/filename_length'

RSpec.describe RuboCop::Cop::FilenameLength do
  it 'does not flag files with names 100 characters long' do
    expect_no_offenses('puts "it does not matter"', 'a' * 100)
  end

  it 'tags files with names 101 characters long' do
    filename = 'a' * 101

    expect_offense(<<~SOURCE, filename)
    source code
    ^ This file name is too long. It should be 100 or less
    SOURCE
  end

  it 'tags files with names 256 characters long' do
    filename = 'a' * 256

    expect_offense(<<~SOURCE, filename)
    source code
    ^ This file name is too long. It should be 100 or less
    SOURCE
  end

  it 'tags files with filepath 256 characters long' do
    filepath = File.join 'a', 'b' * 254

    expect_offense(<<~SOURCE, filepath)
    source code
    ^ This file name is too long. It should be 100 or less
    SOURCE
  end

  it 'tags files with filepath 257 characters long' do
    filepath = File.join 'a', 'b' * 255

    expect_offense(<<~SOURCE, filepath)
    source code
    ^ This file path is too long. It should be 256 or less
    SOURCE
  end
end