Failing to test Devise with Capybara

前端 未结 3 1414
轻奢々
轻奢々 2021-01-02 01:12

I\'m building a Rails 3 app using Devise, with Capybara for UI testing. The following test is failing:

class AuthenticationTest < ActionController::Integ         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-02 01:59

    I was having the same issue and found a thread with a solution:

    RSpec.configure do |config|
      config.use_transactional_fixtures = false
    
      config.before(:suite) do
        DatabaseCleaner.strategy = :truncation
      end
    
      config.before(:each) do
        DatabaseCleaner.start
      end
    
      config.after(:each) do
        DatabaseCleaner.clean
      end
    
    end
    

    For the DatabaseCleaner stuff to work you'll need to include the database_cleaner gem. If you haven't used it before, you may need to rake db:test:prepare before rerunning your tests. I hope this works for you, too!

提交回复
热议问题