mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Change #in_session to #using_session to match #using_driver.
This commit is contained in:
parent
675302884a
commit
fbe8bfec0b
2 changed files with 11 additions and 14 deletions
|
@ -88,12 +88,9 @@ module Capybara
|
|||
|
||||
##
|
||||
#
|
||||
# Switch to a different session, referenced by name, execute the provided block and return to
|
||||
# the default session. This is useful for testing interactions between two browser sessions.
|
||||
# Yield a block using a specific session name.
|
||||
#
|
||||
def in_session(name, &block)
|
||||
return unless block_given?
|
||||
|
||||
def using_session(name)
|
||||
self.session_name = name
|
||||
yield
|
||||
ensure
|
||||
|
@ -118,8 +115,8 @@ module Capybara
|
|||
# Shortcut to working in a different session. This is useful when Capybara is included
|
||||
# in a class or module.
|
||||
#
|
||||
def in_session(name, &block)
|
||||
Capybara.in_session(name, &block)
|
||||
def using_session(name, &block)
|
||||
Capybara.using_session(name, &block)
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -136,10 +136,10 @@ describe Capybara do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#in_session" do
|
||||
describe "#using_session" do
|
||||
it "should change the session name for the duration of the block" do
|
||||
Capybara.session_name.should == :default
|
||||
Capybara.in_session(:administrator) do
|
||||
Capybara.using_session(:administrator) do
|
||||
Capybara.session_name.should == :administrator
|
||||
end
|
||||
Capybara.session_name.should == :default
|
||||
|
@ -147,7 +147,7 @@ describe Capybara do
|
|||
|
||||
it "should reset the session to the default, even if an exception occurs" do
|
||||
begin
|
||||
Capybara.in_session(:raise) do
|
||||
Capybara.using_session(:raise) do
|
||||
raise
|
||||
end
|
||||
rescue Exception
|
||||
|
@ -157,7 +157,7 @@ describe Capybara do
|
|||
|
||||
it "should yield the passed block" do
|
||||
called = false
|
||||
Capybara.in_session(:administrator) { called = true }
|
||||
Capybara.using_session(:administrator) { called = true }
|
||||
called.should == true
|
||||
end
|
||||
end
|
||||
|
@ -196,13 +196,13 @@ describe Capybara do
|
|||
foo.page.body.should include('Another World')
|
||||
end
|
||||
|
||||
it "should provide an 'in_session' shortcut" do
|
||||
it "should provide an 'using_session' shortcut" do
|
||||
klass = Class.new do
|
||||
include Capybara
|
||||
end
|
||||
Capybara.should_receive(:in_session).with(:name)
|
||||
Capybara.should_receive(:using_session).with(:name)
|
||||
foo = klass.new
|
||||
foo.in_session(:name)
|
||||
foo.using_session(:name)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue