mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Remove sleeps from specs
This commit is contained in:
@@ -103,9 +103,9 @@ feature %q{
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
# Then I should see the basic settings
|
||||
sleep(1)
|
||||
page.find('#order_cycle_name').value.should == oc.name
|
||||
page.find('#order_cycle_orders_open_at').value.should == oc.orders_open_at.to_s
|
||||
page.find('#order_cycle_orders_close_at').value.should == oc.orders_close_at.to_s
|
||||
@@ -160,7 +160,7 @@ feature %q{
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
sleep 1
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
# And I update it
|
||||
fill_in 'order_cycle_name', with: 'Plums & Avos'
|
||||
|
||||
@@ -89,6 +89,16 @@ module WebHelper
|
||||
DirtyFormDialog.new(page)
|
||||
end
|
||||
|
||||
# http://www.elabs.se/blog/53-why-wait_until-was-removed-from-capybara
|
||||
# Do not use this without good reason. Capybara's built-in waiting is very effective.
|
||||
def wait_until
|
||||
require "timeout"
|
||||
Timeout.timeout(Capybara.default_wait_time) do
|
||||
sleep(0.1) until value = yield
|
||||
value
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def wait_for_ajax
|
||||
wait_until { page.evaluate_script("$.active") == 0 }
|
||||
|
||||
Reference in New Issue
Block a user