[Chirb] tools, already in play and coming soon
Jake Scruggs
jake.scruggs at gmail.com
Wed Jun 11 10:26:00 EDT 2008
I've been using the NullDb (http://agilewebdevelopment.com/plugins/nulldb)
plugin to disconnect RSpec from the database.
I don't like the global disconnect (for all specs everywhere) that the web
page suggests, so I set up this in my spec_helper:
describe "Unit Spec", :shared => true do
before :all do
ActiveRecord::Base.establish_connection(:adapter => :nulldb)
end
after :all do
ActiveRecord::Base.establish_connection(:test)
end
end
and then say this inside any describe block I want to disconnect from the
db:
require File.dirname(__FILE__) + "/../spec_helper"
describe User do
it_should_behave_like "Unit Spec"
.
.
.
using nested describes to separate my unit (don't hit the db) from my
functional (do hit the db) specs
-Jake
On Wed, Jun 11, 2008 at 8:37 AM, Ryan Platte <ryan at platte.name> wrote:
> 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't have to wait on the slow ones to set up and run.
>
> The fly in the ointment is that schema.rb has to be current.
>
> namespace :spec do
>
> desc "Run all fast specs in spec directory (excluding plugin specs)"
> Spec::Rake::SpecTask.new(:fast) do |t|
> t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
> t.spec_files = FileList['spec/**/*_fast_spec.rb']
> #t.ruby_opts = ['-r spec/spec_helper', '-rubygems', '-runit_record',
> "-e 'ActiveRecord::Base.disconnect!'"]
> end
>
> desc "Run all non-fast specs in spec directory (excluding plugin specs)"
> Spec::Rake::SpecTask.new(:slow => spec_prereq) do |t|
> t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
> t.spec_files =
> FileList['spec/**/*_spec.rb'].exclude('spec/**/*_fast_spec.rb')
> end
>
> end
>
>
> On Wed, Jun 11, 2008 at 1:36 AM, David Chelimsky <dchelimsky at gmail.com>
> wrote:
>
>> On Jun 9, 2008, at 11:31 PM, David Chelimsky wrote:
>>
>> Hey Chirb,
>>>
>>> Lastly, I may have mis-spoke about rails loading up columns from
>>> schema.rb - I'm looking into it and will follow up when I learn the truth.
>>> So Ryan - keep using unit-record for now :)
>>>
>>
>> I definitely mis-spoke. I don't know where I got that in my head, but it
>> seems I did.
>>
>> I don't recall who said it, but unit_record does the column caching I
>> thought rails did. So now it's off to figure out how to get rspec to play
>> nice w/ unit_record.
>>
>> More soon.
>>
>>
>> Cheers,
>> David
>> _______________________________________________
>> ChicagoGroup-Members-List at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/chicagogroup-members-list
>>
>
>
>
> --
> Ryan Platte
> _______________________________________________
> ChicagoGroup-Members-List at rubyforge.org
> http://rubyforge.org/mailman/listinfo/chicagogroup-members-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/chicagogroup-members-list/attachments/20080611/6c250425/attachment-0001.html>
More information about the ChicagoGroup-Members-List
mailing list