Sha256: 6ed5b4d09389b2a60ef0ba689bf63a57402b037704a9d5fb827ccaed2c9e5707
Contents?: true
Size: 973 Bytes
Versions: 7
Compression:
Stored size: 973 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module RSpec # Checks that the second argument to the top level describe is the tested # method name. # # @example # # bad # describe MyClass, 'do something' do # end # # # good # describe MyClass, '#my_instance_method' do # end # # describe MyClass, '.my_class_method' do # end class DescribeMethod < Cop include RuboCop::RSpec::TopLevelDescribe MESSAGE = 'The second argument to describe should be the method ' \ "being tested. '#instance' or '.class'" METHOD_STRING_MATCHER = /^[\#\.].+/ def on_top_level_describe(_node, args) second_arg = args[1] return unless second_arg return if METHOD_STRING_MATCHER =~ second_arg.children.first add_offense(second_arg, :expression, MESSAGE) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems