Sha256: 28adc24cffb9148ec2f11e63d6f27bad139df5873f3f39b9febecfff20e2311a

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

# encoding: utf-8

module RuboCop
  module Cop
    module RSpec
      # 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 ExampleWording < 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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.1.0 lib/rubocop/cop/rspec/example_wording.rb
rubocop-rspec-1.0.1 lib/rubocop/cop/rspec/example_wording.rb
rubocop-rspec-1.0 lib/rubocop/cop/rspec/example_wording.rb
rubocop-rspec-1.0.rc3 lib/rubocop/cop/rspec/example_wording.rb