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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 21:09:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-20 21:09:31 +0300
commitae4ef81757bdd2c984777d8f0b2c275bbcb4b17d (patch)
tree1ac23c80190bafb47a1f5a6f1aae9da91d35d9dc /spec/rubocop/cop/filename_length_spec.rb
parent194b499aa8e26df26ff70a1e1ce0396587bd5243 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/filename_length_spec.rb')
-rw-r--r--spec/rubocop/cop/filename_length_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/rubocop/cop/filename_length_spec.rb b/spec/rubocop/cop/filename_length_spec.rb
new file mode 100644
index 00000000000..1a665440cbc
--- /dev/null
+++ b/spec/rubocop/cop/filename_length_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'rubocop'
+require 'rubocop/rspec/support'
+require_relative '../../../rubocop/cop/filename_length'
+require_relative '../../support/helpers/expect_offense'
+
+describe RuboCop::Cop::FilenameLength do
+ subject(:cop) { described_class.new }
+
+ 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