Sha256: 0240395cf5d3a5681f35cdbbd773cbebe9895ce287ebb9aab5a1d4898b0be1eb

Contents?: true

Size: 928 Bytes

Versions: 17

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # Checks if test cases contain any assertion calls.
      #
      # @example
      #   # bad
      #   class FooTest < Minitest::Test
      #     def test_the_truth
      #     end
      #   end
      #
      #   # good
      #   class FooTest < Minitest::Test
      #     def test_the_truth
      #       assert true
      #     end
      #   end
      #
      class NoAssertions < Base
        include MinitestExplorationHelpers

        MSG = 'Test case has no assertions.'

        def on_class(class_node)
          return unless test_class?(class_node)

          test_cases(class_node).each do |node|
            assertions_count = assertions_count(node)

            next if assertions_count.positive?

            add_offense(node.block_type? ? node.source_range : node.loc.name)
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rubocop-minitest-0.36.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.35.1 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.35.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.5 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.4 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.3 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.2 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.1 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.34.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.33.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.32.2 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.32.1 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.32.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.31.1 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.31.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.30.0 lib/rubocop/cop/minitest/no_assertions.rb
rubocop-minitest-0.29.0 lib/rubocop/cop/minitest/no_assertions.rb