Refactoring: In idiomatic Ruby loops are exited early by return
-ing instead of break
-ing.
This commit is contained in:
parent
3b27e6cb8b
commit
ab43ff94c8
1 changed files with 6 additions and 6 deletions
|
@ -17,18 +17,18 @@ class Capybara::Node::Element
|
||||||
#
|
#
|
||||||
# @return [Capybara::Node::Element] the element/node
|
# @return [Capybara::Node::Element] the element/node
|
||||||
def in_fixed_position(checks: 100)
|
def in_fixed_position(checks: 100)
|
||||||
|
previous = native.location
|
||||||
|
|
||||||
previous = nil
|
(checks + 1).times do
|
||||||
(checks + 1).times do |check|
|
sleep 0.2
|
||||||
raise "Element still moving after #{checks} checks" if check == checks
|
|
||||||
|
|
||||||
current = native.location
|
current = native.location
|
||||||
sleep 0.2
|
|
||||||
break if previous == current
|
return self if previous == current
|
||||||
|
|
||||||
previous = current
|
previous = current
|
||||||
end
|
end
|
||||||
|
|
||||||
self
|
raise "Element still moving after #{checks} checks"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue