1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Raise an error when scope not found on page

This commit is contained in:
Theo Hultberg and Jonas Nicklas 2009-11-16 20:13:57 +01:00 committed by Jonas Nicklas
parent 6e55c86a13
commit 15a713114b
2 changed files with 8 additions and 0 deletions

View file

@ -80,6 +80,7 @@ class Webcat::Session
end end
def within(scope) def within(scope)
raise Webcat::ElementNotFound, "scope '#{scope}' not found on page" if find(scope).empty?
scopes.push(scope) scopes.push(scope)
yield yield
scopes.pop scopes.pop

View file

@ -482,6 +482,13 @@ shared_examples_for "session" do
@session.body.should include('Hello world') @session.body.should include('Hello world')
end end
end end
it "should raise an error if the scope is not found on the page" do
running {
@session.within("//div[@id='doesnotexist']") do
end
}.should raise_error(Webcat::ElementNotFound)
end
end end
context "with forms" do context "with forms" do