I\'m trying to pass this spec :
scenario \"Edit a service\", js: true do
service = create_service_for(provider, title: \"First service\")
fill_edit_service_f
The most probable reason is there must be some query going on through ajax / database cleaner is truncating the database prematurely while sql query is running. One of the method is to make webkit driver wait till the ajax request is finished. Add this method in the test helpers and call it after clicking the button / submitting the ajax form.
def wait_for_ajax_to_finish
looping = true
loop do
sleep 1
begin
count = page.evaluate_script('window.running_ajax_calls').to_i
looping = false if count == 0
rescue => e
if e.message.include? 'HTMLunitCorejsJavascript::Undefined'
raise "For 'wait for the AJAX call to finish' to work, please include culerity.js after including jQuery."
else
raise e
end
end
end
end