These are both good techniques.  RSpec docs do suggest that model  
specs hit the db (whereas in unit testing this is typically  
discouraged), due to the fact that your model and ActiveRecord are  
difficult to separate from each other.

The reason why isolation is encouraged in unit testing, is because of  
performance and ease of tracking down what caused a test failure when  
they occur.

Cheers,
Josh

On 10/10/2008, at 10:23 AM, Anthony Richardson wrote:

> On Fri, Oct 10, 2008 at 9:50 AM, Torm3nt <[EMAIL PROTECTED]> wrote:
> Can someone explain to me why you shouldn't be hitting the db...  
> especially with model specs? Or is this more for controller specs,  
> whereby you mock out the model (which I do already)?
>
>
> Because it's slow. If what you are testing isn't DB specific why  
> suffer the penalty? There are a couple of solutions I have seen for  
> making your tests run all in memory. On is the set you test db as  
> SQLite with an inmemory dataset, the other was a plugin that hacked  
> AR to not make DB calls.
>
> Cheers,
>
> Anthony Richardson
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to