lib/rubocop/cop/rspec/example_length.rb in rubocop-rspec-1.12.0 vs lib/rubocop/cop/rspec/example_length.rb in rubocop-rspec-1.13.0

- old
+ new

@@ -26,32 +26,29 @@ # expect(result).to be(true) # end class ExampleLength < Cop include CodeLength - EXAMPLE_BLOCKS = RuboCop::RSpec::Language::Examples::ALL + MSG = 'Example has too many lines [%d/%d].'.freeze def on_block(node) - method, _args, _body = *node - _receiver, method_name, _object = *method - return unless EXAMPLE_BLOCKS.include?(method_name) + return unless example?(node) length = code_length(node) return unless length > max_length + add_offense(node, :expression, message(length)) end private def code_length(node) - lines = node.source.lines[1..-2] - - lines.count { |line| !irrelevant_line(line) } + node.source.lines[1..-2].count { |line| !irrelevant_line(line) } end def message(length) - format('Example has too many lines. [%d/%d]', length, max_length) + format(MSG, length, max_length) end end end end end