[rspec-users] Problem of using fixture in Rspec

aslak hellesoy aslak.hellesoy at gmail.com
Mon Aug 13 04:07:00 EDT 2007

On 8/13/07, Shaker <flyeminent at hotmail.com> wrote:
> Dear Fellows:
>     I was using fixtures in the model tests using Rspec. I found that the
> test data specified in the fixtures was stored in the test database once I
> ran the spec and won't be removed anyway. Is my observation correct?

Yes, this is how Rails does it.

>     There might be another problem regarding the fixtures. When I ran the
> specs one by one, it was working. However, it failed when I tried to run all
> the specs in one command. It seemed that the test data which was modified by
> one spec caused the other spec which accessed that particular data to fail.
> In other words, the data is actually kind of public to all specs, so the
> specs shares one copy of test data.
>     If my observation is correct, are there any ways to overcome these
> problems? Is it possible that each single spec owns its test data so that
> the modifications on the data will not affect other specs?

My hunch is that you'll get the same behaviour with Test::Unit (try it).

You probably need to tell your spec that it must use more fixture
tables, to clean up before each example (it block).


>     Cheers!
> --
> View this message in context: http://www.nabble.com/Problem-of-using-fixture-in-Rspec-tf4258669.html#a12119520
> Sent from the rspec-users mailing list archive at Nabble.com.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list