Skip to main content


Showing posts from March, 2016

Rolify, Devise, Rspec and Capybara Webkit in Rails

So I was using Rolify, Devise, Rspec and Capybara Webkit in Rails and I ran into a problem with the Warden login_as helper when trying to do a feature spec with :js => true (if you didn't understand any of that, you are probably on the wrong blog). Anyways, while the I was able to log in an admin, Rolify was not able to determine the roles. This is in spite of the fact that I added a role in Factory Girl. FactoryGirl.define do factory :admin do email { } password "password" password_confirmation "password" trait :administrator do after(:create) {|admin| admin.add_role(:administrator)} end end end This worked fine with js turned off, so why was it not working now? So the answer had to do with the following line in rails_helper.rb config.use_transactional_fixtures = true So I believe what happened in Capybara webkit is that it runs in a different thread and while Warden's login_as worked fine