Permalink
Browse files

Adds reset_session_after_each config option. Closes #418

  • Loading branch information...
1 parent b0dbaf8 commit 1476cd9c8f442211055a706fe1410db40e4639fb @kberridge kberridge committed Jul 18, 2011
Showing with 23 additions and 2 deletions.
  1. +2 −0 lib/capybara.rb
  2. +1 −1 lib/capybara/rspec.rb
  3. +20 −1 spec/rspec_spec.rb
View
@@ -17,6 +17,7 @@ class << self
attr_accessor :server_port, :server_boot_timeout
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements, :prefer_visible_elements
attr_accessor :save_and_open_page_path
+ attr_accessor :reset_session_after_each
##
#
@@ -236,6 +237,7 @@ module Selenium
config.ignore_hidden_elements = false
config.prefer_visible_elements = true
config.default_host = "http://www.example.com"
+ config.reset_session_after_each = true
end
Capybara.register_driver :rack_test do |app|
@@ -13,7 +13,7 @@
# might not actually be used in all examples where it's included.
config.after do
if self.class.include?(Capybara::DSL)
- Capybara.reset_sessions!
+ Capybara.reset_sessions! if Capybara.reset_session_after_each
Capybara.use_default_driver
end
end
View
@@ -15,12 +15,31 @@
page.body.should include('Cookie set to test_cookie')
end
- it "...then it is not availbable in the next" do
+ it "...then it is not available in the next" do
visit('/get_cookie')
page.body.should_not include('test_cookie')
end
end
+ context "resetting session disabled" do
+ before(:all) do
+ Capybara.reset_session_after_each = false
+ end
+ after(:all) do
+ Capybara.reset_session_after_each = true
+ end
+
+ it "sets a cookie in one example..." do
+ visit('/set_cookie')
+ page.body.should include('Cookie set to test_cookie')
+ end
+
+ it "...then it is available in the next" do
+ visit('/get_cookie')
+ page.body.should include('test_cookie')
+ end
+ end
+
context "setting the current driver" do
it "sets the current driver in one example..." do
Capybara.current_driver = :selenium

0 comments on commit 1476cd9

Please sign in to comment.