Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90 state:resolved]
This commit is contained in:
parent
8b652bd036
commit
3e3d8e3659
@ -65,6 +65,7 @@
|
|||||||
|
|
||||||
* Bug fixes
|
* Bug fixes
|
||||||
|
|
||||||
|
* Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90]
|
||||||
* Match against link _text_ which decodes character references.
|
* Match against link _text_ which decodes character references.
|
||||||
Useful for multibyte languages like Japanese (moronatural@gmail.com)
|
Useful for multibyte languages like Japanese (moronatural@gmail.com)
|
||||||
* Fix params hash generation for Mechanize when Merb is not defined [#62]
|
* Fix params hash generation for Mechanize when Merb is not defined [#62]
|
||||||
|
@ -30,6 +30,10 @@ module Webrat
|
|||||||
def initialize(session, &block) #:nodoc:
|
def initialize(session, &block) #:nodoc:
|
||||||
@session = session
|
@session = session
|
||||||
instance_eval(&block) if block_given?
|
instance_eval(&block) if block_given?
|
||||||
|
|
||||||
|
if @selector && scoped_element.nil?
|
||||||
|
raise Webrat::NotFoundError.new("The scope was not found on the page: #{@selector.inspect}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Verifies an input field or textarea exists on the current page, and stores a value for
|
# Verifies an input field or textarea exists on the current page, and stores a value for
|
||||||
@ -291,7 +295,7 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def scoped_dom #:nodoc:
|
def scoped_dom #:nodoc:
|
||||||
source = Webrat::XML.to_html(Webrat::XML.css_search(@scope.dom, @selector).first)
|
source = Webrat::XML.to_html(scoped_element)
|
||||||
|
|
||||||
if @session.xml_content_type?
|
if @session.xml_content_type?
|
||||||
Webrat::XML.xml_document(source)
|
Webrat::XML.xml_document(source)
|
||||||
@ -300,6 +304,10 @@ module Webrat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def scoped_element
|
||||||
|
Webrat::XML.css_at(@scope.dom, @selector)
|
||||||
|
end
|
||||||
|
|
||||||
def locate_field(field_locator, *field_types) #:nodoc:
|
def locate_field(field_locator, *field_types) #:nodoc:
|
||||||
if field_locator.is_a?(Field)
|
if field_locator.is_a?(Field)
|
||||||
field_locator
|
field_locator
|
||||||
|
@ -97,4 +97,16 @@ describe "within" do
|
|||||||
}.should raise_error(Webrat::NotFoundError)
|
}.should raise_error(Webrat::NotFoundError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should raise a Webrat::NotFounderror error when the scope doesn't exist" do
|
||||||
|
with_html <<-HTML
|
||||||
|
<html>
|
||||||
|
</html>
|
||||||
|
HTML
|
||||||
|
|
||||||
|
lambda {
|
||||||
|
within "#form2" do
|
||||||
|
end
|
||||||
|
}.should raise_error(Webrat::NotFoundError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user