There is a race condition here between Capybara sending the click action to the server and your test checking the database.
The easiest way to resolve this is to wait until validation:
expect { click_button "Create"; sleep 2 }.to change(Answer, :count).by(count)
I do not like it. The best way to verify this would be end-user verification.
For example, after clicking the Create button, does the user see the answer on the answer page?
fill_in :title, :with => "My answer" click_button 'Create' page.should have_text "My answer"
source share