[rspec-users] Collection proxies need to be stubbed ?
dchelimsky at gmail.com
Sun Jan 21 07:36:01 EST 2007
On 1/21/07, Tobias Grimm <listaccount at e-tobi.net> wrote:
> David Chelimsky wrote:
> > this. If it's a user stored in the session, I don't agree that it
> > should come from the User class. I would probably stick the mock user
> > in the session though, rather than stub the method.
> Agreed - if it's in the session, this should be the preferred way.
> > Because specs run faster when you don't rely on the database. You're
> > going to be spec'ing all the same stuff in your model specs, so why
> > hit the database more than you need to?
> I don't have any experience with RSpec/Rails using a database - my
> current Rails project is DB-less :-) But on a recent C# project (with
> NUnit) I've chosen to just use a database in my tests. It wasn't even an
> in-memory database (embedded Firebird) but it was still fast enough with
> several hundred tests hitting the database.
What's fast enough?
When doing BDD or TDD, the goal is to run the specs (tests) as often
as possible, after every little change. I run my specs dozens (if not
hundreds) of times a day, so a difference of a few seconds adds up to
a big difference.
>Rails with SQLite in memory
> should even be faster. So speed isn't really much of an issue in my
> But you're right that stubbing database access should be preferred.
> Sometimes it's just easier to put complex data into a fixture and
> retrieve it from the database. Maybe that's a design smell - I'll keep
> this in mind when I run into this situation the next time.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users