[Nitro] Nitro/OG spec questions

gabriele renzi rff_rff at yahoo.it
Fri Sep 7 06:03:16 EDT 2007


On Fri, 07 Sep 2007 18:35:14 +1000, Mark Van De Vyver wrote:

> I'm not familiar with the spec infrastructure - I assume starting a
> spec in a new file ensure your starting 'from-scratch'?  Have I missed
> something obvious?

AFAIK all specs are loaded together, so even sticking to single spec per
source is not useful but see later.
 
> Choices:
> stick with single spec file per source, and just wrestle (and cross
> fingers). split the sources and maintain on spec file per source file
> (may/ may not fully solve the issue?).
> adopt some convention for multiple spec files per source (pointless if
> this doesn't over come the above problem).
> 
> Comments/thoughts/tips?

use 
 before {block}
 after {block} 
for setup something between every "it" and 
 before :all {} 
 after :all {}
for whole-spec setup/teardown

i.e. I have tests like

describe "foo" do
 before :all { Og.setup(:dbfile=>'test.db' } 	#run at the start of spec

 after { Foo.delete_all }			#run between every spec 
 
 it 'should create XYZ" {Foo.create("arg"); Foo.count.should == 1}

 after :all {File.delete('test.db') }		#run at end for cleanup
end

This is general good practice for tests.



-- 
goto 10: http://www.goto10.it
blog it: http://riffraff.blogsome.com
blog en: http://www.riffraff.info



More information about the Nitro-general mailing list