[rspec-users] Where to put macros

Ben Mabey ben at benmabey.com
Mon Jun 22 12:44:42 EDT 2009


On Jun 22, 2009, at 10:37 AM, David Chelimsky wrote:

> On Mon, Jun 22, 2009 at 11:28 AM, Andrew Premdas<apremdas at gmail.com>  
> wrote:
>> Recently I got some wonderful help from the list to create my  
>> NamedAddress
>> module/macro which tests NamedAddresses for a number of different  
>> resources.
>> The question I have is where should I put this module? At the  
>> moment I've
>> got it in spec_helper, but this feels a bit messy
>> Many thanks
>> Andrew
>
> The convention that I see emerging is to keep macros, helpers, and any
> other spec supporting material in spec/support/macros,
> spec/support/matchers, etc. Then you do this in spec/spec_helper.rb:
>
> Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
>
> What would folks think if that was included in the generated
> spec_helper in spec-rails?

Just as I said there was no written convention... :)

I like it.  +1

-Ben


More information about the rspec-users mailing list