Class: RuboCop::Cop::RSpec::Extra::RestrictBlockTagValue
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::RSpec::Extra::RestrictBlockTagValue
- Includes:
- Metadata
- Defined in:
- lib/rubocop/cop/rspec/extra/restrict_block_tag_value.rb
Overview
Restrict to only allowed block tag value.
Constant Summary collapse
- MSG =
"This value is not allowed in this tag. Allowed tag value: %<allow_tag_value>s."
Instance Method Summary collapse
Instance Method Details
#on_metadata(_symbols, hash) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/rspec/extra/restrict_block_tag_value.rb', line 22 def (_symbols, hash) return if hash.nil? offenses = hash.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 |