Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c868db
commit 8a8e8cc
Showing
6 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
When /^I say "([^"]*)"$/ do |message| | |||
fill_in "Message", :with => message | |||
click_button "Send" | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,5 @@ | |||
Given /^I have signed in as "([^"]*)"$/ do |name| | Given /^I am signed in as "([^"]*)"$/ do |name| | ||
visit "/sign_in" | |||
fill_in "Name", :with => name | fill_in "Name", :with => name | ||
click_button "Go" | click_button "Go" | ||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
Given /^I have a browser with "([^"]*)" signed in$/ do |name| | |||
switch_session(name) | |||
And %{I am signed in as "#{name}"} | |||
end | |||
|
|||
When /^I switch browsers to "([^"]*)"$/ do |name| | |||
switch_session(name) | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
# Author: Eric Pierce | |||
# http://www.automation-excellence.com/blog/racking-my-brains | |||
module Capybara | |||
module Driver | |||
module Sessions | |||
def set_session(id) | |||
Capybara.instance_variable_set('@session_pool', { | |||
"#{Capybara.current_driver}#{Capybara.app.object_id}" => $sessions[id] | |||
}) | |||
end | |||
|
|||
def switch_session(id) | |||
$sessions ||= {} | |||
$sessions[:default] ||= Capybara.current_session | |||
$sessions[id] ||= Capybara::Session.new(Capybara.current_driver, Capybara.app) | |||
set_session(id) | |||
end | |||
|
|||
def in_session(id, &block) | |||
switch_session(id) | |||
yield | |||
set_session(:default) | |||
end | |||
end | |||
end | |||
end | |||
|
|||
World(Capybara::Driver::Sessions) |