title: Rspec capybara User cannot login
body: <p>Testing devise sign in using capybara. It seems something is wrong as i cannot test sign in using rspec and capybara. Im using factory girl to define user </p>
  
  <pre><code>FactoryGirl.define do
   factory :user do
    email 'admin@revol-tech.com.np'
    password 'bhaktapur'
    password_confirmation 'bhaktapur'
    admin true
    name 'admin'
    confirmation_sent_at "#{DateTime.now}"
    confirmation_token 'anupsumhikichiki'
    confirmed_at "#{DateTime.now}"
    username 'username'
   end
  end
  </code></pre>
  
  <p>Here is my spec_helper.rb</p>
  
  <pre><code># This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'
  require 'capybara/rspec'
  require 'database_cleaner'
  # FactoryGirl.find_definitions
  Capybara.current_driver = :selenium
  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  RSpec.configure do |config|
   config.include Devise::TestHelpers, :type =&gt; :controller
   config.before(:suite) do
   DatabaseCleaner.strategy = :transaction
   DatabaseCleaner.clean_with :truncation
  end
  
  config.before(:each) do
   DatabaseCleaner.start
  end
  # config.after(:each) {  }
  config.after(:each) do
   DatabaseCleaner.clean
   Warden.test_reset!
  end
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
  config.use_transactional_fixtures = false
  
  # If true, the base class of anonymous controllers will be inferred
  # automatically. This will be the default behavior in future versions of
  # rspec-rails.
  config.infer_base_class_for_anonymous_controllers = false
  end
  </code></pre>
  
  <p>And here is my spec </p>
  
  <pre><code>require_relative '../spec_helper.rb'
  include Warden::Test::Helpers
  Warden.test_mode!
  
  feature "the signin process" do
  before :each do
  @user_attr = FactoryGirl.attributes_for(:user)
  # @user = FactoryGirl (:user)
  User.create!(@user_attr)
  end
  
  scenario "signs me in"  do
    # login_as @user, :scope =&gt; :user
    visit '/'
    fill_in 'Login', :with =&gt; "admin@revol-tech.com.np"
    fill_in 'Password', :with =&gt; "bhaktapur"
    click_button 'Sign in'
    page.should have_content "Signed in successfully"
    Warden.test_reset! 
   end
  end
  </code></pre>
  
  <p>Also my User model is set to confirmable</p>