I’m an infrequent user of Capybara, preferring other means to test. But I reach for it when it’s needed. That being said, I haven’t been up to speed on all the features of more recent releases.
One thing that I’d been used to in writing tests is explicitly putting
sleep when the stack is switching pages in the middle of a
test, and checking the
current_url matches a given path.
Instead, as of version 2.5, there’s a method called
(which evolves to
have_current_path in RSpec matchers)
that works with Capybara’s wait time (i.e., the test waits until the
current path satisifies the argument given) which gives a much cleaner
test than inserting sleeps.
has_current_path? will take either a string or a regexp.)