If you are using factories, and your models have a bunch of required associations, then only getting your factories to persist their data to the DB when strictly necessary should provide a speed bump. The latest version of factory_girl supports a :method => :build option on associations that means the association will only be saved when the parent is. This means you can do a Factory.build(:whatever) without it triggering a bunch of inserts on associated tables.<div>
<br></div><div>Alternatively Fabrication (<a href="http://fabricationgem.org/">http://fabricationgem.org/</a>) supports lazy creation of associations, but it does so via some rather invasive overwriting of association methods, which is less than ideal.</div>
<div><div><br></div><div>It's no substitute for decoupling your business models from AR, but it's a quick and (relatively) easy win.</div><div><br></div><div>Cheers,</div><div>Simon<br><div><div><br><div class="gmail_quote">
On 24 January 2012 10:07, Mark Burns <span dir="ltr"><<a href="mailto:markthedeveloper@gmail.com">markthedeveloper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Preferring mocks over factories can help. Spork can help too by preloading the Rails environment.<div>That's tended to be enough for me, although you can do distributed tests too.</div><div><br></div><div><a href="https://www.ruby-toolbox.com/categories/distributed_testing" target="_blank">https://www.ruby-toolbox.com/categories/distributed_testing</a></div>


<div><br></div><div>Also I presume you're not hitting the web, but if you are then VCR with WebMock is good</div><div class="HOEnZb"><div class="h5"><div><br><br><div class="gmail_quote">On 24 January 2012 19:02, Jonathan <span dir="ltr"><<a href="mailto:j.fantham@gmail.com" target="_blank">j.fantham@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Mine are really slow, but yesterday Glenn made a suggestion of using a<br>
ramdisk to speed the database access which seemed like a good idea! I<br>
haven't had the opportunity to try it yet but I read into it and if<br>
you're on *nix it seems pretty easy to do.<br>
<br>
On 24 January 2012 09:57, Joel Chippindale<br>
<div><div><<a href="mailto:joel.chippindale@econsultancy.com" target="_blank">joel.chippindale@econsultancy.com</a>> wrote:<br>
> Test speed seems to be a perennial issue for our team.<br>
><br>
> Currently running a single spec file in our rails (v3.0, running under REE)<br>
> app takes about 20 seconds and running a single cucumber scenario 30+<br>
> seconds. This is too slow for comfortable test driven development/design.<br>
><br>
> We've recently started using the spec_no_rails pattern (as outlined by Corey<br>
> Haines<br>
> here <a href="http://www.confreaks.com/videos/641-gogaruco2011-fast-rails-tests" target="_blank">http://www.confreaks.com/videos/641-gogaruco2011-fast-rails-tests</a>) to<br>
> avoid loading rails, in some of our specs. This has enabled us to run some<br>
> of our specs in couple of seconds (i.e. fast enough). However this currently<br>
> only applies to the small subset of our specs that we have isolated from<br>
> rails. We'd like it if all our tests ran this fast.<br>
><br>
> How fast are your tests/specs/cucumber? Are they fast enough for you? If<br>
> they are, what have you done to make this so?<br>
><br>
> J.<br>
><br>
> --<br>
> Joel Chippindale<br>
> CTO - <a href="http://econsultancy.com" target="_blank">http://econsultancy.com</a><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Chat mailing list<br>
> <a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
> <a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
><br>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Simon Coffey<br>Developer, Tribesports<br><a href="mailto:simon@tribesports.com" target="_blank">simon@tribesports.com</a> | 07960 004 857<br>
</div></div></div></div>