Sorcery/Capybara: Cannot log in with :js => true


I've been using capybara for a while, but I'm new to sorcery. I have a very odd problem whereby if I run the specs without Capybara's :js => true functionality I can log in fine, but if I try to specify :js => true on a spec, username/password cannot be found.

Here's the authentication macro:

module AuthenticationMacros
  def sign_in
    user = FactoryGirl.create(:user)
    user.activate!
    visit new_sessions_path
    fill_in 'Email Address', :with => user.email
    fill_in 'Password', :with => 'foobar'
    click_button 'Sign In'
    user
  end
end

Which is called in specs like this:

feature "project setup" do
  include AuthenticationMacros

  background do
    sign_in
  end

  scenario "creating a project" do
    "my spec here"
  end

The above code works fine. However, IF I change the scenario spec from (in this case)

scenario "adding questions to a project" do

to

scenario "adding questions to a project", :js => true do

login fails with an 'incorrect username/password' combination. Literally the only change is that :js => true. I'm using the default capybara javascript driver. (Loads up Firefox)

Any ideas what could be going on here? I'm completely stumped. I'm using Capybara 2.0.1, Sorcery 0.7.13. There is no javascript on the sign in page and save_and_open_page before clicking 'sign in' confirms that the correct details are entered into the username/password fields. Any suggestions really appreciated - I'm at a loss.

The default capybara javascript driver is Selenium according to the capybara doc. Because Selenium executes in a separate thread, you have to disable transactional fixtures or the Selenium thread will not have access to the data you create in the database. See https://github.com/jnicklas/capybara#using-capybara-with-testunit. That section has these notes about disabling transactional fixtures.