Labels should only search for fields within the current scope
This commit is contained in:
parent
14d114ce1d
commit
6529a016d1
@ -23,7 +23,7 @@ module Webrat
|
||||
if for_id.blank?
|
||||
Webrat::XML.xpath_at(@element, *Field.xpath_search)
|
||||
else
|
||||
Webrat::XML.css_search(@session.dom, "#" + for_id).first
|
||||
Webrat::XML.css_search(@session.current_dom, "#" + for_id).first
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -124,6 +124,27 @@ describe "within" do
|
||||
end
|
||||
end
|
||||
|
||||
it "should not find fields outside of the scope" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
<form id="form1" action="/form1">
|
||||
<label for="email">Email</label><input id="email" type="text" name="email" />
|
||||
<input type="submit" value="Add" />
|
||||
</form>
|
||||
<form id="form2" action="/form2">
|
||||
<label for="email">Email</label><input id="email" type="text" name="email" />
|
||||
<input type="submit" value="Add" />
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
webrat_session.should_receive(:get).with("/form2", "email" => "test@example.com")
|
||||
within "#form2" do
|
||||
fill_in "Email", :with => "test@example.com"
|
||||
click_button "Add"
|
||||
end
|
||||
end
|
||||
|
||||
it "should not find buttons outside of the scope" do
|
||||
with_html <<-HTML
|
||||
<html>
|
||||
|
Loading…
Reference in New Issue
Block a user