Sorcery/Capybara: Cannon log in with :js => true
Posted
by
PlankTon
on Stack Overflow
See other posts from Stack Overflow
or by PlankTon
Published on 2012-12-14T05:01:54Z
Indexed on
2012/12/14
5:03 UTC
Read the original article
Hit count: 229
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.
© Stack Overflow or respective owner