lib/rubocop/cop/rspec/example_wording.rb in rubocop-rspec-2.14.1 vs lib/rubocop/cop/rspec/example_wording.rb in rubocop-rspec-2.14.2

- old
+ new

@@ -66,24 +66,19 @@ it_description(node) do |description_node, message| if message.match?(SHOULD_PREFIX) add_wording_offense(description_node, MSG_SHOULD) elsif message.match?(IT_PREFIX) add_wording_offense(description_node, MSG_IT) - else - check_and_handle_insufficient_examples(description_node) + elsif insufficient_docstring?(description_node) + add_offense(docstring(description_node), + message: MSG_INSUFFICIENT_DESCRIPTION) end end end private - def check_and_handle_insufficient_examples(description) - if insufficient_examples.include?(preprocess(text(description))) - add_wording_offense(description, MSG_INSUFFICIENT_DESCRIPTION) - end - end - def add_wording_offense(node, message) docstring = docstring(node) add_offense(docstring, message: message) do |corrector| next if node.heredoc? @@ -133,9 +128,13 @@ cop_config.fetch('CustomTransform', {}) end def ignored_words cop_config.fetch('IgnoredWords', []) + end + + def insufficient_docstring?(description_node) + insufficient_examples.include?(preprocess(text(description_node))) end def insufficient_examples examples = cop_config.fetch('DisallowedExamples', []) examples.map! { |example| preprocess(example) }