single test failing after changing to capybara-webkit single test failing after changing to capybara-webkit selenium selenium

single test failing after changing to capybara-webkit


There is a race condition here between Capybara sending the click action to the server and your test checking the database.

The simplest way to resolve this is to wait before checking:

expect { click_button "Create"; sleep 2 }.to change(Answer, :count).by(count)

I don't like this. A better way to test this would be to check from the end user's perspective.

For example, after clicking 'Create', does the user see the answer on the answers page?

fill_in :title, :with => "My answer"click_button 'Create'page.should have_text "My answer"