- Add
capybara-webkit
to yourGemfile
and let Guard::Bundler install it automatically (or manually viabundle install
if you don’t use Guard).
1
|
|
- Set Javascript driver to
:webkit
for Capybara inspec_helper.rb
.
1
|
|
Configure RSpec use non-transactional fixtures, configure Database Cleaner in
spec_helper.rb
.Notice with this setup, we’ll only use truncation strategy when driver is not
:rack_test
. this will make normal specs run faster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
- Tag your scenarios in
spec/acceptance/*_spec.rb
to use Javascript driver if necessary.
1 2 |
|
Wait for any AJAX call to be completed in your specs. This is very important, or you will get many strange issues like no database record found, AJAX call get empty response with 0 status code, etc.
For example if you have a simple AJAX form, the
success
callback will simply redirect browser to another page vialocation.href = '/yet_another_page';
. You can use the following code to wait for it done.
1 2 3 4 5 6 7 8 9 |
|