lib/rubocop/cop/rspec/capybara/current_path_expectation.rb in rubocop-rspec-1.32.0 vs lib/rubocop/cop/rspec/capybara/current_path_expectation.rb in rubocop-rspec-1.33.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module RuboCop
module Cop
module RSpec
module Capybara
# Checks that no expectations are set on Capybara's `current_path`.
@@ -22,25 +24,25 @@
# expect(page).to have_current_path(/widgets/)
#
class CurrentPathExpectation < Cop
MSG = 'Do not set an RSpec expectation on `current_path` in ' \
'Capybara feature specs - instead, use the ' \
- '`have_current_path` matcher on `page`'.freeze
+ '`have_current_path` matcher on `page`'
def_node_matcher :expectation_set_on_current_path, <<-PATTERN
(send nil? :expect (send {(send nil? :page) nil?} :current_path))
PATTERN
# Supported matchers: eq(...) / match(/regexp/) / match('regexp')
def_node_matcher :as_is_matcher, <<-PATTERN
(send
- #expectation_set_on_current_path ${:to :not_to :to_not}
+ #expectation_set_on_current_path $#{Runners::ALL.node_pattern_union}
${(send nil? :eq ...) (send nil? :match (regexp ...))})
PATTERN
def_node_matcher :regexp_str_matcher, <<-PATTERN
(send
- #expectation_set_on_current_path ${:to :not_to :to_not}
+ #expectation_set_on_current_path $#{Runners::ALL.node_pattern_union}
$(send nil? :match (str $_)))
PATTERN
def on_send(node)
expectation_set_on_current_path(node) do