thoughtbot/capybara-webkit — Issue #222: Loses user session between before block and it block
Author: tvdeyen
Created: 2011-12-01 15:20:09+00:00
State: open

```
describe Alchemy::Admin::PagesController do

describe "language tree switching", :js => true do

context "in a multilangual environment" do

before(:all) do
Factory.build(:admin_user).save_without_session_maintenance
Factory(:language)
visit '/alchemy/admin/login'
fill_in('alchemy_user_session_login', :with => 'jdoe')
fill_in('alchemy_user_session_password', :with => 's3cr3t')
click_on('Login')
end

it "one should be able to switch the language tree" do
visit('/alchemy/admin/pages')
page.select 'Klingonian', :from => 'language'
save_and_open_page
end

end

end

end
```

Fails!

```
describe Alchemy::Admin::PagesController do

describe "language tree switching", :js => true do

context "in a multilangual environment" do

before(:all) do
Factory.build(:admin_user).save_without_session_maintenance
Factory(:language)
end

it "one should be able to switch the language tree" do
visit '/alchemy/admin/login'
fill_in('alchemy_user_session_login', :with => 'jdoe')
fill_in('alchemy_user_session_password', :with => 's3cr3t')
click_on('Login')
visit('/alchemy/admin/pages')
page.select 'Klingonian', :from => 'language'
save_and_open_page
end

end

end

end
```

Passes!

If I omit the `:js => true` part (running with default `rack_test` driver), than both tests pass.

NOTE: The `save_and_open_page` calls are only to see if the correct page shows up. In the real test there is an matcher.