Sha256: 9c213ef51cc5f8a61d8c1cb05e90fbf161665148f7cc60ae508c4948542732fa

Contents?: true

Size: 1.15 KB

Versions: 34

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "test_helper"
require "statsd/instrument/rubocop"

module Rubocop
  class MetricValueKeywordArgumentTest < Minitest::Test
    include RubocopHelper

    def setup
      @cop = RuboCop::Cop::StatsD::MetricValueKeywordArgument.new
    end

    def test_ok_for_method_without_arguments
      assert_no_offenses("StatsD.increment")
    end

    def test_ok_for_non_metric_method
      assert_no_offenses("StatsD.backend('foo', value: 1)")
    end

    def test_ok_with_no_keywords
      assert_no_offenses("StatsD.increment('foo', 1)")
    end

    def test_ok_with_no_matching_keyword
      assert_no_offenses("StatsD.increment('foo', 1, tags: ['foo'])")
      assert_no_offenses("StatsD.increment('foo', 1, tags: { value: 'bar' })")
    end

    def test_offense_with_value_keyword
      assert_offense("StatsD.increment('foo', value: 1)")
      assert_offense("StatsD.increment('foo', :value => 1)")
      # assert_offense("StatsD.increment('foo', 'value' => 1)")
      assert_offense("StatsD.increment('foo', sample_rate: 0.1, value: 1, tags: ['foo'])")
      assert_offense("StatsD.increment('foo', value: 1, &block)")
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
statsd-instrument-3.9.9 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.8 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.7 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.6 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.5 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.4 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.3 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.2 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.1 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.9.0 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.8.0 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.7.0 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.6.1 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.6.0 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.12 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.11 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.10 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.9 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.8 test/rubocop/metric_value_keyword_argument_test.rb
statsd-instrument-3.5.7 test/rubocop/metric_value_keyword_argument_test.rb