From ab43ff94c87cb00e71c6974a01a803ec65d342b6 Mon Sep 17 00:00:00 2001 From: Mantas Date: Tue, 25 Aug 2020 00:15:24 +0300 Subject: [PATCH] Refactoring: In idiomatic Ruby loops are exited early by `return`-ing instead of `break`-ing. --- spec/support/capybara/custom_extensions.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/support/capybara/custom_extensions.rb b/spec/support/capybara/custom_extensions.rb index 51689e15b..096f95c51 100644 --- a/spec/support/capybara/custom_extensions.rb +++ b/spec/support/capybara/custom_extensions.rb @@ -17,18 +17,18 @@ class Capybara::Node::Element # # @return [Capybara::Node::Element] the element/node def in_fixed_position(checks: 100) + previous = native.location - previous = nil - (checks + 1).times do |check| - raise "Element still moving after #{checks} checks" if check == checks + (checks + 1).times do + sleep 0.2 current = native.location - sleep 0.2 - break if previous == current + + return self if previous == current previous = current end - self + raise "Element still moving after #{checks} checks" end end