Sha256: 853e406cde40d9dc02aa47832dfb3cd9eecea797c184d7e3a56fbee0d6da7e26

Contents?: true

Size: 719 Bytes

Versions: 2

Compression:

Stored size: 719 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    # Do not use should when describing your tests.
    # see: http://betterspecs.org/#should
    #
    # @example
    #   # bad
    #   it 'should find nothing' do
    #   end
    #
    #   # good
    #   it 'finds nothing' do
    #   end
    class RSpecExampleWording < Cop
      MSG = 'Do not use should when describing your tests.'

      def on_block(node)
        method, _, _ = *node
        _, method_name, *args = *method

        return unless method_name == :it

        arguments = *(args.first)
        message = arguments.first.to_s
        return unless message.start_with?('should')

        add_offense(method, :selector, MSG)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rspec-1.0.rc2 lib/rubocop/cop/rspec_example_wording.rb
rubocop-rspec-1.0.rc1 lib/rubocop/cop/rspec_example_wording.rb