Class: RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation
- Inherits:
-
RuboCop::Cop::RSpec::Cop
- Object
- WorkaroundCop
- RuboCop::Cop::RSpec::Cop
- RuboCop::Cop::RSpec::Capybara::CurrentPathExpectation
- Defined in:
- lib/rubocop/cop/rspec/capybara/current_path_expectation.rb
Overview
Checks that no expectations are set on Capybara’s ‘current_path`.
The ‘have_current_path` matcher (www.rubydoc.info/github/ teamcapybara/capybara/master/Capybara/RSpecMatchers#have_current_path- instance_method) should be used on `page` to set expectations on Capybara’s current path, since it uses Capybara’s waiting functionality (github.com/teamcapybara/capybara/blob/master/ README.md#asynchronous-javascript-ajax-and-friends) which ensures that preceding actions (like ‘click_link`) have completed.
Constant Summary collapse
- MSG =
'Do not set an RSpec expectation on `current_path` in ' \ 'Capybara feature specs - instead, use the ' \ '`have_current_path` matcher on `page`'.freeze
Constants inherited from RuboCop::Cop::RSpec::Cop
RuboCop::Cop::RSpec::Cop::DEFAULT_CONFIGURATION, RuboCop::Cop::RSpec::Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from RuboCop::Cop::RSpec::Cop
Instance Method Details
#on_send(node) ⇒ Object
33 34 35 36 37 |
# File 'lib/rubocop/cop/rspec/capybara/current_path_expectation.rb', line 33 def on_send(node) expectation_set_on_current_path(node) do add_offense(node, location: :selector) end end |