Sha256: 48ee6821dc5d3ab8215f4ed1b104a67cc06ca60f8ca67c36f3fdd429cd0d808e
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
Contents
require 'rubocop-rspec' module Gitlab module Styles module Rubocop module Cop module RSpec # This cop checks for unused parameters to the `have_link` matcher. # # @example # # # bad # expect(page).to have_link('Link', 'https://example.com') # # # good # expect(page).to have_link('Link', href: 'https://example.com') # expect(page).to have_link('Example') class HaveLinkParameters < RuboCop::Cop::RSpec::Cop MESSAGE = "The second argument to `have_link` should be a Hash.".freeze def_node_matcher :unused_parameters?, <<~PATTERN (send nil? :have_link _ !{hash nil} ) PATTERN def on_send(node) return unless unused_parameters?(node) location = node.arguments[1..-1] .map(&:source_range) .reduce(:join) add_offense(node, location: location, message: MESSAGE) end end end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems