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


I've been stumped on this.

Everything goes fine on the tutorial, but when I add this part of the code to my /spec/requests/users_spec.rb file, things start to go south: < Pre> describe "success" should be "create a new user" lambadai signup_path fill_in "name", go along with: = with & gt; "Example User" fill_in "email" ,:: with = & gt; "Ryan@example.com" fill_in "password" ,:: with = & gt; "Fobor" fill_fill "confirmation" ,:: with = & gt; "Fobar" click_button response. Should_selector ("div.flash.success" ,: content = & gt; "welcome") response. Render_template ('Users / Show') End Change (user, count) .by (1) end and end

If I clear Test database (Rake dB: Test: Ready), then all tests pass but if I If I run the test again, they fail because the test database does not clear the records that the above code has been added above.

I have gone a lot, and what I have found, most of them in config.use_transactional_fixtures settings, or on the issue of nesting in the code.

I'm pretty sure that none of these is my case here. Here is my spec_helper.rb file:

  'rubygems' is required 'spark' Sparks Preforking ANV ["Railway_NV"]] = 'Exam' is required File.expand_path (".. /../config/environment", __FILE__) Requires 'rspec / rails' Dir [Rails.root.join ("Spec / support / ** / * .rb")]. Each {| F | Configure the required f} RSPC. Config | Config.mock_with: rspec config.fixture_path = "# {:: Rails.root} / spec / fixtures" config.use_transactional_fixtures = true # Spark is required for ActiveSupport :: dependencies. Load End Spork.each_run "# {Rail Route} /config/routes.rb" Dir ["# {Rails.root} / app / ** / * .rb"] Each {| F | Load f} end   

and here's my users_spec.rb:

  Description of the description "description" of "user" describes "failure" "Do not create a new user" lambda signup_pid filling "name", with: =; "" Fill_in "Email" ,:: with = & gt; "" Fill_in "Password" ,:: with = & gt; "Fill_in" Confirmation ",:: with = & gt; ("User / new ') response.should render_template (' user / new ')). _golator (" div # error_explanation ") end.should_not change (user, count) describes" success "in the end" new user Should create "do lambda do signup_path fill_in" name ",: with =>" example user "fill_in" email ",: with = & gt;" Ryan@example.com "fill_in" password ", with: & Quot; Confirmation & quot; & quot; Fobore & quot ;, & quot; Confirmation & quot ;,: ==> "Fobar" click_button response should be_selector ("div.flash.success" ,: content = & gt; "welcome") response. Render_template ( ' User / show ') will change (user, count) .by (1) end and end end   

any thoughts? Thanks.

mpapis Reply With this, I was able to get this work. Here is my updated SPEC / request / user_spirr file:

  requires 'space_helper' to be 'database_clanner' DatabaseCleaner .strategy =: Description of "user" describes "signup" describes failure "Do it" should not be a new user "lambda signup_path_ fill_in" name ",: = with & gt; "" Fill_in "Email" ,:: with = & gt; "" Fill_in "Password" ,:: with = & gt; "Fill_in" Confirmation ",:: with = & gt; ("User / new ') response.should render_template (' user / new ')). _golator (" div # error_explanation ") end.should_not change (user, count) describes" success "in the end" new user Should create "do lambda do signup_path fill_in" name ",: with =>" example user "fill_in" email ",: with = & gt;" Ryan@example.com "fill_in" password ", with: & Quot; Confirmation & quot; & quot; Fobore & quot ;, & quot; Confirmation & quot ;,: ==> "Fobar" click_button response should be_ selector ("div.flash.success" ,: content = & gt; "welcome") response. Render_template ( ' User / show ') will change the end (user, count) .by (1) database classifier scaler end and end    

As far as the idea is concerned, leaving the database in the ambiguous state, you should try that it is used for cleaning after cucumber testing, but an example for the buck Available on the main page.

Comments