Sha256: bf31253b670669491f2518b3878716082197a53da9610759c8dc304386ce10a8
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module RSpec module Extra # Restrict to only allowed block tag value. # # @example AllowTagValues: { foo: 'baz' } # # bad # RSpec.describe 'Something', foo: :bar do # end # # # good # RSpec.describe 'Something', foo: :baz do # end # class RestrictBlockTagValue < Base include Metadata MSG = "This value is not allowed in this tag. Allowed tag value: %<allow_tag_value>s." def on_metadata(_symbols, pairs) offenses = pairs.filter do |pair| allow_tag_values.any? do |k, v| pair.key.value.to_s == k && pair.value.value.to_s != v end end return unless offenses.any? offenses.each do |offense| add_offense(offense, message: format(MSG, allow_tag_value: allow_tag_values[offense.key.value.to_s])) end end private def allow_tag_values cop_config.fetch("AllowTagValues", {}) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-extra-0.1.0 | lib/rubocop/cop/rspec/extra/restrict_block_tag_value.rb |