Scott Taylor
2007-Jul-24 02:03 UTC
[rspec-users] Dealing with nested/namespaced classes w/ describe
Hi all, Just wondering about this: I''ve been dealing with classes/modules nested in several layers of namespaces. Here would be an example of a describe block: describe ClassOne::ClassTwo::ClassThree, "description here" do ... end What would be the easiest way to write something a little more terse, like: describe ClassThree, "description here" do ... end If this has come up before, just tell me to google. Thanks for your time, Scott Taylor
Kyle Hargraves
2007-Jul-24 02:15 UTC
[rspec-users] Dealing with nested/namespaced classes w/ describe
Scott Taylor wrote:> Hi all, > > Just wondering about this: I''ve been dealing with classes/modules > nested in several layers of namespaces. Here would be an example of > a describe block: > > describe ClassOne::ClassTwo::ClassThree, "description here" do > ... > end > > What would be the easiest way to write something a little more terse, > like: > > describe ClassThree, "description here" do > ... > end > > If this has come up before, just tell me to google. > > Thanks for your time, > > Scott TaylorYou can put the descriptions inside of modules. AFAICT, this has no effect on how anything functions, it just lets you drop the namespacing ugliness from your code: module SomeProject class SomeClass end end module SomeProject describe SomeClass, "something or other" do end end Kyle
Scott Taylor
2007-Jul-24 04:12 UTC
[rspec-users] Dealing with nested/namespaced classes w/ describe
Ah. Thank you. That is just a wonderful solution. Much better than the solution of redefining a new constant. Best, Scott On Jul 23, 2007, at 10:15 PM, Kyle Hargraves wrote:> Scott Taylor wrote: >> Hi all, >> >> Just wondering about this: I''ve been dealing with classes/modules >> nested in several layers of namespaces. Here would be an example of >> a describe block: >> >> describe ClassOne::ClassTwo::ClassThree, "description here" do >> ... >> end >> >> What would be the easiest way to write something a little more terse, >> like: >> >> describe ClassThree, "description here" do >> ... >> end >> >> If this has come up before, just tell me to google. >> >> Thanks for your time, >> >> Scott Taylor > > You can put the descriptions inside of modules. AFAICT, this has no > effect on how anything functions, it just lets you drop the > namespacing > ugliness from your code: > > module SomeProject > class SomeClass > end > end > > module SomeProject > > describe SomeClass, "something or other" do > end > > end > > Kyle > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users