Class: CukeLinter::TestNameWithTooManyCharactersLinter

Inherits:
Linter
  • Object
show all
Defined in:
lib/cuke_linter/linters/test_name_with_too_many_characters_linter.rb

Overview

A linter that detects test names that are too long

Constant Summary collapse

DEFAULT_TEST_NAME_LENGTH_THRESHOLD =

The threshold used if not otherwise configured

80

Instance Attribute Summary

Attributes inherited from Linter

#name

Instance Method Summary collapse

Methods inherited from Linter

#initialize, #lint

Constructor Details

This class inherits a constructor from CukeLinter::Linter

Instance Method Details

#configure(options) ⇒ Object

Changes the linting settings on the linter using the provided configuration



10
11
12
# File 'lib/cuke_linter/linters/test_name_with_too_many_characters_linter.rb', line 10

def configure(options)
  @test_name_length_threshold = options['TestNameLengthThreshold'] if options['TestNameLengthThreshold']
end

#messageObject

The message used to describe the problem that has been found



24
25
26
# File 'lib/cuke_linter/linters/test_name_with_too_many_characters_linter.rb', line 24

def message
  "Scenario name is too long. #{@linted_test_name_length} characters found (max #{test_name_length_threshold})"
end

#rule(model) ⇒ Object

The rule used to determine if a model has a problem



15
16
17
18
19
20
21
# File 'lib/cuke_linter/linters/test_name_with_too_many_characters_linter.rb', line 15

def rule(model)
  return false unless model.is_a?(CukeModeler::Scenario) || model.is_a?(CukeModeler::Outline)

  @linted_test_name_length = model.name.nil? ? 0 : model.name.length

  @linted_test_name_length > test_name_length_threshold
end