Database not being cleared when using Capybara and RSPEC -


I have recently encountered some problems with my database. At first I thought this was a factory mess problem, but Then I realized that the factory (probably) in the factory was not really using the data which was not cleaned.

Anyway, for the first time I have a new user. I then log in as a user and navigate to that page, where I can create a new "foo" with the data field "foo_name" and "bar" Next, I fill_in with "": = & Gt; "Fields" and click_button "save" to create a new "foo" object, then I see the new object's pointer and it should be 1, but every time I run the exam, the number increases to 4 . (It's at 72 now)

In addition to this, I think I must remove the old user at the beginning of the test or factory, complain that the user has already been created.

I was almost certain that RSPEEE had managed to remove the test database for me, am I wrong? And if so, is there any good advice on the "good" way to clean a database?

Thank you very much.

Edit (Some example code requests have been made):

  ... context can "create a new buzz" {search_link ('New Foo Bar') To do before. Click here to enter "current_path" / foo_bar / new "current_path.should == '/ Foo_bar / new' end context" When the correct information is given "before filling {fill_in 'name', with: = 'TestFooBar 'Fill_in' description ', with: & gt;' A test foo bar 'click_button' save '} has current_path in "/ foo_bars"' current_path.should == '/ foo_bars' end ...    

Anyone else is in the future , This problem has been solved. Like the Xeteset, I'm just like the conventional fixtures of Canberra.

To fix this problem, I am using database cleaner.

gem install database_cleaner

  Jeff : Group: Test by Mani 'database_claimer' and   

bundle install

spec / spec_helper.rb:

  config Use_transactional_fixtures = false ... module :: RSpec :: code class example group cipaBada :: DSL includes CAPEBARA :: RSPCmaters End and << / code>  

foo_bar file:

  First (: all) {... after DatabaseCleaner.strategy =: truncation} (: All) {... DatabaseCleaner.clean Capybara.reset_sessions! Capybara.use_default_driver}    

Comments