RailsTutorial - chapter 8.4.3 - Test database not clearing after adding user in integration test

后端 未结 2 1323
难免孤独
难免孤独 2020-12-10 07:38

I\'m stumped on this one.

Everything on the tutorial has gone smoothly so far, but when I add this chunk of code to my /spec/requests/users_spec.rb file, things star

相关标签:
2条回答
  • 2020-12-10 08:27

    As far as I'm concerned testing views leaves database in unclear state, you should try https://github.com/bmabey/database_cleaner it is used for cleaning after cucumber tests, but an example for Rspec is available on the main page.

    0 讨论(0)
  • 2020-12-10 08:27

    mpapis' answer got it to work.

    Be sure to include it in your GEMFILE for example:

    group :test do
        gem 'rspec', '2.5.0'
        gem 'webrat', '0.7.1'
        gem 'spork', '0.9.0.rc4'
        gem 'factory_girl_rails'
        gem 'database_cleaner'
    end    
    

    and

    bundle install
    
    0 讨论(0)
提交回复
热议问题