I&#39;ve been using the NullDb (<a href="http://agilewebdevelopment.com/plugins/nulldb">http://agilewebdevelopment.com/plugins/nulldb</a>) plugin to disconnect RSpec from the database.<br><br>I don&#39;t like the global disconnect (for all specs everywhere) that the web page suggests, so I set up this in my spec_helper:<br>
<br>describe &quot;Unit Spec&quot;, :shared =&gt; true do<br>
&nbsp; before :all do<br>
&nbsp;&nbsp;&nbsp; ActiveRecord::Base.establish_connection(:adapter =&gt; :nulldb)<br>
&nbsp; end<br>
<br>
&nbsp; after :all do<br>
&nbsp;&nbsp;&nbsp; ActiveRecord::Base.establish_connection(:test)<br>
&nbsp; end<br>
end<br><br>and then say this inside any describe block I want to disconnect from the db:<br><br>require File.dirname(__FILE__) + &quot;/../spec_helper&quot;<br><br>describe User do<br>&nbsp; it_should_behave_like &quot;Unit Spec&quot;<br>
.<br>.<br>.<br><br>using nested describes to separate my unit (don&#39;t hit the db) from my functional (do hit the db) specs<br><br>-Jake <br><br><div class="gmail_quote">On Wed, Jun 11, 2008 at 8:37 AM, Ryan Platte &lt;<a href="mailto:ryan@platte.name">ryan@platte.name</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Here are some Rake tasks I created to use RSpec with UnitRecord. I set the default task to first run spec:fast, then spec:slow, so if the fast ones fail we don&#39;t have to wait on the slow ones to set up and run.</div>

<div><br></div><div>The fly in the ointment is that schema.rb has to be current.</div><div><br></div><div>namespace :spec do</div><div><br></div><div>&nbsp;&nbsp;desc &quot;Run all fast specs in spec directory (excluding plugin specs)&quot;</div>

<div>&nbsp;&nbsp;Spec::Rake::SpecTask.new(:fast) do |t|</div><div>&nbsp;&nbsp; &nbsp;t.spec_opts = [&#39;--options&#39;, &quot;\&quot;#{RAILS_ROOT}/spec/spec.opts\&quot;&quot;]</div><div>&nbsp;&nbsp; &nbsp;t.spec_files = FileList[&#39;spec/**/*_fast_spec.rb&#39;]</div>

<div>&nbsp;&nbsp; &nbsp;#t.ruby_opts = [&#39;-r spec/spec_helper&#39;, &#39;-rubygems&#39;, &#39;-runit_record&#39;, &quot;-e &#39;ActiveRecord::Base.disconnect!&#39;&quot;]</div><div>&nbsp;&nbsp;end</div><div><br></div><div>&nbsp;&nbsp;desc &quot;Run all non-fast specs in spec directory (excluding plugin specs)&quot;</div>

<div>&nbsp;&nbsp;Spec::Rake::SpecTask.new(:slow =&gt; spec_prereq) do |t|</div><div>&nbsp;&nbsp; &nbsp;t.spec_opts = [&#39;--options&#39;, &quot;\&quot;#{RAILS_ROOT}/spec/spec.opts\&quot;&quot;]</div><div>&nbsp;&nbsp; &nbsp;t.spec_files = FileList[&#39;spec/**/*_spec.rb&#39;].exclude(&#39;spec/**/*_fast_spec.rb&#39;)</div>

<div>&nbsp;&nbsp;end</div><div><br></div><div>end</div><div><div></div><div class="Wj3C7c"><div><br></div><br><div class="gmail_quote">On Wed, Jun 11, 2008 at 1:36 AM, David Chelimsky &lt;<a href="mailto:dchelimsky@gmail.com" target="_blank">dchelimsky@gmail.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Jun 9, 2008, at 11:31 PM, David Chelimsky wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey Chirb,<div><br>
<br>
Lastly, I may have mis-spoke about rails loading up columns from schema.rb - I&#39;m looking into it and will follow up when I learn the truth. So Ryan - keep using unit-record for now :)<br>
</div></blockquote>
<br>
I definitely mis-spoke. I don&#39;t know where I got that in my head, but it seems I did.<br>
<br>
I don&#39;t recall who said it, but unit_record does the column caching I thought rails did. So now it&#39;s off to figure out how to get rspec to play nice w/ unit_record.<br>
<br>
More soon.<div><div></div><div><br>
<br>
Cheers,<br>
David<br>
_______________________________________________<br>
<a href="mailto:ChicagoGroup-Members-List@rubyforge.org" target="_blank">ChicagoGroup-Members-List@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/chicagogroup-members-list" target="_blank">http://rubyforge.org/mailman/listinfo/chicagogroup-members-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br></div></div>-- <br><font color="#888888">Ryan Platte
</font><br>_______________________________________________<br>
<a href="mailto:ChicagoGroup-Members-List@rubyforge.org">ChicagoGroup-Members-List@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/chicagogroup-members-list" target="_blank">http://rubyforge.org/mailman/listinfo/chicagogroup-members-list</a><br></blockquote></div><br>