Class: RuboCop::Cop::InSpecStyle::FileBeMounted

Inherits:
RuboCop::Cop
  • Object
show all
Defined in:
lib/rubocop/cop/inspecstyle/file_be_mounted.rb

Overview

file resource deprecates matchers ‘be_mounted.with` and `be_mounted.only_with` in favor of the mount resource

Constant Summary collapse

MSG =
'Use the `:mount` resource instead of `be_mounted.%<violation>s` ' \
"\nThis matcher will be removed in InSpec 5"

Instance Method Summary collapse

Instance Method Details

#on_block(node) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rubocop/cop/inspecstyle/file_be_mounted.rb', line 37

def on_block(node)
  return unless inside_file_spec?(node)
  node.descendants.each do |descendant|
    deprecated_file_matcher?(descendant) do |violation|
      add_offense(
        descendant,
        location: offense_range(descendant),
        message: format(
          MSG,
          violation: violation
        )
      )
    end
  end
end