extend dont_find to Capybara::Element

This commit is contained in:
John Bintz 2013-02-25 13:50:25 -05:00
parent d2fac8e685
commit b9e14eac0c
2 changed files with 28 additions and 16 deletions

View File

@ -89,5 +89,9 @@ Sometimes the absence of a thing is just as important as the presence of a thing
# selector's not there
dont_find('#user')
# ...after you've already found something...
find('.node').dont_find('.something_inside')
```

View File

@ -62,6 +62,26 @@ def find_object_action(object, action)
find("[data-type='#{object}'][data-action='#{action}']")
end
module DontFindable
def dont_find_wrap(search)
yield
sleep Capybara.default_wait_time
yield
raise Capybara::ElementFound.new(search)
rescue Capybara::ElementNotFound
true
end
def dont_find(search)
dont_find_wrap(search) do
find(search)
end
end
end
module Capybara
class ElementFound < StandardError
def initialize(search)
@ -72,26 +92,14 @@ module Capybara
@search
end
end
end
def dont_find_wrap(search)
yield
sleep Capybara.default_wait_time
yield
raise Capybara::ElementFound.new(search)
rescue Capybara::ElementNotFound
true
end
def dont_find(search)
dont_find_wrap(search) do
find(search)
class Node::Element
include DontFindable
end
end
include DontFindable
def dont_find_object(object)
case object
when Class