Put the describe in the module, and take advantage of Ruby's lookup semantics:
module Foo module Baz describe Class1 do ... Pat On 1/25/09, Stuart Hungerford <stuart.hungerf...@anu.edu.au> wrote: > Hi, > > I've got a set of classes in nested Ruby modules which I'm using rspec > to specify: > > module Foo > > module Baz > > class C1 ... end > > class C2 ... end > end > end > > To specify C2 behaviour I need to create a bunch of C1 instances: > > describe Foo::Baz::C2 do > > before(:each) do > @c1a = Foo::Baz::C1.new(...) > @c1b = Foo::Baz::C1.new(...) > @c1c = Foo::Baz::C1.new(...) > > @c2 = Foo::Baz::C2.new(@c1a, @c1b, @c1c) > end > > describe "some behaviour" do > # ... > end > end > > After a while the many Foo::Baz:: module prefixes become pretty > tedious and > not particularly DRY. > > Can someone suggest a better way to manage using nested modules in > rspec? > > Thanks, > > Stu > > -- > Stuart Hungerford > ANU Supercomputer Facility > > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users