[rspec-users] Separating black sheep examples from the rest

Matt Wynne matt at mattwynne.net
Wed Sep 24 06:25:22 EDT 2008

On 23 Sep 2008, at 17:11, Ben Mabey wrote:

> Matt Wynne wrote:
>> So we've got a pretty decent number of specs now, and despite my best
>> efforts, AR is just forcing us down the path of having to use  
>> database
>> interaction for some of the model specs.
>> To turn my real database on for individual examples this is the  
>> code I use:
>   unless Object.const_defined?(:Functional)
>     share_as :Functional do
>       before :all do
>         ActiveRecord::Base.establish_connection(:test)
>       end
>       after :all do
>         ActiveRecord::Base.establish_connection(:adapter => :nulldb)
>       end
>     end
>   end
> Then in the example I say:
> describe "when there are ten users in the database" do
>   include Functional
>   ....
> end
> I have actually also implemented what you have suggested so I can  
> also say:
> describe "when there are ten users in the database", :functional =>  
> true do
> ...
> end
> HTH,

That helps a huge amount. Can't wait to have some time to dig into  
this. Thanks Ben.


In case you wondered: The opinions expressed in this email are my own  
and do not necessarily reflect the views of any former, current or  
future employers of mine.

More information about the rspec-users mailing list