Sha256: acd6d3e59b28af711d395d2df7247b1cfc6ec88eafba37fdc7aea5fd33560d5f
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
require 'chutney/linter' require 'engtagger' module Chutney # service class to lint for avoiding periods class BeDeclarative < Linter MESSAGE = 'This step does not contain a verb'.freeze def initialize super end def lint filled_scenarios do |file, feature, scenario| scenario[:steps].each do |step| references = [reference(file, feature, scenario, step)] add_warning(references, MESSAGE) unless verb? step end end end def verb?(step) tagged = tagger.add_tags step[:text] step_verbs = verbs tagged !step_verbs.empty? end def verbs(tagged_text) verbs = %i[ get_infinitive_verbs get_past_tense_verbs get_gerund_verbs get_passive_verbs get_present_verbs get_base_present_verbs ] verbs.map { |verb| tagger.send(verb, tagged_text).keys }.flatten end def tagger @tagger = EngTagger.new unless instance_variable_defined? :@tagger @tagger end end end
Version data entries
5 entries across 5 versions & 1 rubygems