mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge branch 'master' of github.com:jnicklas/capybara
This commit is contained in:
commit
e5f3a92cc9
2 changed files with 22 additions and 2 deletions
|
@ -173,11 +173,20 @@ module Capybara
|
||||||
# fill_in('Street', :with => '12 Main Street')
|
# fill_in('Street', :with => '12 Main Street')
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# @param (see Capybara::Node::Finders#all)
|
# @overload within(*find_args)
|
||||||
|
# @param (see Capybara::Node::Finders#all)
|
||||||
|
#
|
||||||
|
# @overload within(a_node)
|
||||||
|
# @param [Capybara::Node::Base] a_node The node in whose scope the block should be evaluated
|
||||||
|
#
|
||||||
# @raise [Capybara::ElementNotFound] If the scope can't be found before time expires
|
# @raise [Capybara::ElementNotFound] If the scope can't be found before time expires
|
||||||
#
|
#
|
||||||
def within(*args)
|
def within(*args)
|
||||||
new_scope = find(*args)
|
new_scope = if args.size == 1 && Capybara::Node::Base === args.first
|
||||||
|
args.first
|
||||||
|
else
|
||||||
|
find(*args)
|
||||||
|
end
|
||||||
begin
|
begin
|
||||||
scopes.push(new_scope)
|
scopes.push(new_scope)
|
||||||
yield
|
yield
|
||||||
|
|
|
@ -38,6 +38,17 @@ shared_examples_for "within" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with Node rather than selector" do
|
||||||
|
it "should click links in the given scope" do
|
||||||
|
node_of_interest = @session.find(:css, "ul li[contains('With Simple HTML')]")
|
||||||
|
|
||||||
|
@session.within(node_of_interest) do
|
||||||
|
@session.click_link('Go')
|
||||||
|
end
|
||||||
|
@session.body.should include('Bar')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with the default selector set to CSS" do
|
context "with the default selector set to CSS" do
|
||||||
before { Capybara.default_selector = :css }
|
before { Capybara.default_selector = :css }
|
||||||
it "should use CSS" do
|
it "should use CSS" do
|
||||||
|
|
Loading…
Reference in a new issue