On Wed, May 11, 2011 at 1:54 PM, egervari <ken.egerv...@gmail.com> wrote:

> Hi everyone!
>
> I have a question on how to setup my tests a bit differently than the
> defaults.
>
> By default, Rails with RSpec installed provides you with directories
> such as spec/models, spec/controllers, etc.
>
> When i use before(:each), I notice that Rails properly cleans out the
> database in these specs automatically.
>
> However, I created a new sub-directory called spec/queries. My
> intention was to put all of my query-related tests here so that the
> database setup code didn't run with the model validation and business
> logic tests (for speed and organization reasons). I will have a lot of
> complex queries that will need to be tested against a mini-database...
> so this seems like the right thing to do (or is there a better
> solution?)
>
> When I put these tests in spec/queries folder and run the tests
> multiple times, Rails complains that data is not unique and so on...
> so I am guessing that the data is not getting cleaned out now? Yes, I
> am using factory girl with sequences, so this is probably a database
> cleaning problem. I didn't have it before when these same tests were
> in 'specs/models'.
>
> 1. Do I need to manually clean out the data since I moved the specs
> into it's own spec/squeries subdirectory?
>
> 2. Is there any way to include spec/queries to the list of directories
> that get auto-cleaned, much like spec/models does?
>

There is a gem called database_cleaner which might help in your case to run
before your test/suite.


>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to