class RuboCop::Cop::Mavenlint::UseFastCapybaraMatchers
Identify usages of `to_not` with a Capybara matcher, which will be really slow.
For example
expect(page).to_not have_text('Hi')
Writing an assertion this way will first try to find the text 'Hi'. If not present, Capybara will wait for the full timeout (often 30 seconds) before then inverting with `to_not` and passing.
Instead, we should do something like:
expect(page).to have_no_text('Hi')
Which will pass as soon as the text is not detected without any timeout.
Constants
- CAPYBARA_MATCHERS
- MSG
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/mavenlint/use_fast_capybara_matchers.rb, line 32 def on_send(node) return unless slow_capybara_matcher?(node) add_offense(node) end
Private Instance Methods
capybara?(symbol)
click to toggle source
# File lib/rubocop/cop/mavenlint/use_fast_capybara_matchers.rb, line 40 def capybara?(symbol) CAPYBARA_MATCHERS.include?(symbol) end