[rspec-users] Dealing with nested/namespaced classes w/ describe

Kyle Hargraves philodespotos at gmail.com
Mon Jul 23 22:15:29 EDT 2007


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


More information about the rspec-users mailing list