class RuboCop::Cop::Bugcrowd::SleepySpecs
@example
# bad sleep 1 expect(page).to have_content('blah') # good expect(page).to have_content('blah', wait: 3)
github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends www.varvet.com/blog/why-wait_until-was-removed-from-capybara/ www.reddit.com/r/rails/comments/25xrdy/is_there_a_way_to_change_capybaras_wait_time_just/
Other methods of avoiding sleep:
-
Use an intermediate matcher
“` expect(page).to have_content(flash_mesage) # the fast action expect(page).to have_content(activity_message) # the slow action “`
-
Don't rely on something that is inherently slow
- instead of waiting for the page to be updated you can check that the correct behavior is called (this can sometimes make the test less robust)
Constants
- MSG
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/bugcrowd/sleepy_specs.rb, line 41 def on_send(node) return unless sleeping?(node) add_offense(node) end