Sha256: a1bdf18a2f0c91523a53b6656764771c7aef0523966368f8c5e72f7a7863931f

Contents?: true

Size: 660 Bytes

Versions: 4

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    module Minitest
      # This cop enforces the test to use `refute_in_delta`
      # instead of using `refute_equal` to compare floats.
      #
      # @example
      #   # bad
      #   refute_equal(0.2, actual)
      #   refute_equal(0.2, actual, 'message')
      #
      #   # good
      #   refute_in_delta(0.2, actual)
      #   refute_in_delta(0.2, actual, 0.001, 'message')
      #
      class RefuteInDelta < Cop
        include InDeltaMixin

        def_node_matcher :equal_floats_call, <<~PATTERN
          (send nil? :refute_equal $_ $_ $...)
        PATTERN
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-minitest-0.10.3 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.10.2 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.10.1 lib/rubocop/cop/minitest/refute_in_delta.rb
rubocop-minitest-0.10.0 lib/rubocop/cop/minitest/refute_in_delta.rb