[rspec-devel] [ rspec-Bugs-6570 ] rSpec on Rails does not clean the test DB inbetween contexts

noreply at rubyforge.org noreply at rubyforge.org
Thu Nov 9 05:42:33 EST 2006


Bugs item #6570, was opened at 2006-11-08 18:45
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6570&group_id=797

Category: rails plugin
Group: None
Status: Closed
Resolution: Rejected
Priority: 3
Submitted By: Timm Gebhart (onkeltimm)
Assigned to: Aslak Hellesøy (aslak_hellesoy)
Summary: rSpec on Rails does not clean the test DB inbetween contexts

Initial Comment:
Version:
RSpec-0.7.0 (r1039)

When I set up a context and load fixtures, those are not removed from the test DB before the next context is run, like this:

# This runs fine
context "Context with fixtures" do
  fixtures :tests

  specify "should have records" do
    Test.find(:all).should_not_be_empty
  end
end

# This fails
context "Context w/o fixtures" do
  specify "should have no records" do
    Test.should_have(:no).records
  end
end

The Test DB should be clean upon entering a context.

----------------------------------------------------------------------

>Comment By: Timm Gebhart (onkeltimm)
Date: 2006-11-09 11:42

Message:
I might be misunderstanding, but this does not make sense to
me at all. 

The reason there is a test database in the first place is
that it gives you a reliable state at the beginning of each
context/test/spec. To me, this implies that when i do not
load fixtures at all, I get an empty DB (and this IS a
boundary condition, and I have to test it).

Also between different model's *_spec.rb files, the DB is
never cleaned.
How can I ensure I have a DB that is clean except for the
structure in a contest/test/spec?

I'd be happy to be enlightened, but this does seem like a
design error to me. Wonder if I should bring this up in
Rails core, what do you think?

----------------------------------------------------------------------

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2006-11-08 21:35

Message:
This is by design in Rails. You would get the same behaviour if you used Test::Unit

Just put fixtures :tests in the other context too. Or put it in the spec_helper.rb

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6570&group_id=797


More information about the rspec-devel mailing list