[Nitro] Nitro/Og rspec heads-up: any alternative solutions.

Mark Van De Vyver mvyver at gmail.com
Fri Nov 23 02:29:25 EST 2007


Hi resurrecting this thread with a solution...

On Oct 9, 2007 7:36 PM, * William <william.full.moon at gmail.com> wrote:
>
> Hi
>
> ... I often have been know to make names like:
>
>   *  class Class_test_001
>          @desc = 'this tests something-K or another"
>      end
>
> you use the desc to tell what's IN the test ;)
>
> w.
>
>
>
>
> On 09/10/2007, Jonathan Buch <john at oxyliquit.de> wrote:
> > Hi,
> >
> > > The essential point is that rspec describe blocks are not isolated name
> spaces.
> > > Consequence: if you're going to define classes then you'll need to
> > > choose different class names for each describe/example block, or else
> > > the spec's will run a good chance of being contaminated.
> >
> > one more point for the old Test::Unit! ;D
> >
> > But nah, I guess we just have to adhere to some naming scheme...
> > Or packing each spec into a module (which is quite unnice with Og where
> > the generated table name changes)...
> >
> >

>From Aslay on the RSpec users mail list, you can clean up classes
'after' each example in the following example shows:

module Example
 describe "A class defined in before" do
   before do
     class Item
       @@var ||= 0
       @@var += 1

       def self.var
         @@var
       end
     end
   end

   it "should be redefined the first time" do
     Item.var.should == 1
   end

   it "should be redefined the second time" do
     Item.var.should == 1
   end

   after do
     Example.send(:remove_const, 'Item')
   end
 end
end


HTH
Mark

>
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general
>


More information about the Nitro-general mailing list