Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM. [#105 state:resolved]
This commit is contained in:
parent
ebd9d8ed52
commit
cdf9908f9e
@ -68,6 +68,8 @@
|
||||
|
||||
* Bug fixes
|
||||
|
||||
* Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
|
||||
[#105] (Zach Dennis)
|
||||
* Support Rails > v2.2 by using ActionController::RequestParser for param parsing [#107]
|
||||
(Marcello Nuccio)
|
||||
* Raise a Webrat::NotFoundError if the scope passed to #within doesn't exist [#90]
|
||||
|
@ -31,7 +31,7 @@ module Webrat
|
||||
@session = session
|
||||
instance_eval(&block) if block_given?
|
||||
|
||||
if @selector && scoped_element.nil?
|
||||
if @selector && scoped_dom.nil?
|
||||
raise Webrat::NotFoundError.new("The scope was not found on the page: #{@selector.inspect}")
|
||||
end
|
||||
end
|
||||
@ -316,17 +316,7 @@ module Webrat
|
||||
return dom
|
||||
end
|
||||
|
||||
def scoped_dom #:nodoc:
|
||||
source = Webrat::XML.to_html(scoped_element)
|
||||
|
||||
if @session.xml_content_type?
|
||||
Webrat::XML.xml_document(source)
|
||||
else
|
||||
Webrat::XML.html_document(source)
|
||||
end
|
||||
end
|
||||
|
||||
def scoped_element
|
||||
def scoped_dom
|
||||
Webrat::XML.css_at(@scope.dom, @selector)
|
||||
end
|
||||
|
||||
|
@ -59,7 +59,6 @@ describe "within" do
|
||||
end
|
||||
|
||||
it "should work when the scope is inside the form" do
|
||||
pending "needs bug fix" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<form id="form2" action="/form2">
|
||||
@ -77,6 +76,51 @@ describe "within" do
|
||||
end
|
||||
|
||||
submit_form "form2"
|
||||
end
|
||||
|
||||
it "should work when the form submission occurs inside a scope" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<form id="form2" action="/form2">
|
||||
<label for="email">Email</label><input id="email" type="text" class="email2" name="email" />
|
||||
<input type="submit" value="Add" />
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
|
||||
within "form[@action='/form2']" do
|
||||
fill_in "Email", :with => "test@example.com"
|
||||
click_button "Add"
|
||||
end
|
||||
end
|
||||
|
||||
it "should work when there are multiple forms with the same label text" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<form id="form1" action="/form1">
|
||||
<label for="email1">Email</label><input id="email1" type="text" class="email1" name="email1" />
|
||||
<input type="submit" value="Add" />
|
||||
</form>
|
||||
<form id="form2" action="/form2">
|
||||
<label for="email2">Email</label><input id="email2" type="text" class="email2" name="email2" />
|
||||
<input type="submit" value="Add" />
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
webrat_session.should_receive(:get).with("/form2", "email2" => "test@example.com")
|
||||
within "form[@action='/form2']" do
|
||||
fill_in "Email", :with => "test@example.com"
|
||||
click_button "Add"
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user