On 15 December 2010 11:58, Robert Gravina <[email protected]> wrote:

> On 15 December 2010 07:52, dnagir <[email protected]> wrote:
> > Hi Guys,
> >
> > I am a bit tired of waiting for for the [rails 3] specs to run after I
> > save a file. After saving, I have to wait 10 secs or so for my specs
> > only to be executed (by autotest).
> >
>
> 10 seconds! That sounds positively snappy compared to what I have to
> endure. I have some individual specs in one (Rails 2.3.9) app that
> take longer than that (!), and whole suite takes 2 - 3 hours on my
> machine.... which makes using autotest impossible :(.


I think the whole suite should be revisited and re-implemented. Most of the
time tests are getting slow when we touch external dependencies (which
includes a database). So the first thing that will be most notable is to get
rid of those dependencies.

Most of the time we don't really want to test the persistence, but rather
how XYZ behaves.

My problem is that I am too lazy to properly isolate database tests, so most
of the time I just use fixtures with SQLite database instead of
stubbing/mocking.

SQLite database is much faster to run than any other for the tests.

So the first thing to do is to try to isolate Database access. First try
SQLite, then try to hack to use SQLite in-memory DB, then srub and mock.



> Some tests create 10 - 15 models, are parse some big json
> file before running *each* example, so I have a fair idea why they are
> running so slowly.
>
The time cost of creating 100 objects is ridiculously cheap. Parsing JSON is
relatively cheap.
Expensive is the interaction with the database.


>
> Has anyone seen some examples of rspec + factory girl + setup before
> all tests in the wild? I've found Pretty much every rspec + factory
> girl example I can find uses the standard before do ... end block for
> setup as it's probably fine for most test suites.... maybe I need to
> just search the githubs?
>

Here is one (small) that I work on from time to time:
https://github.com/dnagir/connecty
I use factory_girl with SQLite.
The speed of specs themselves is not a concern for me, but rather the
startup time.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or 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