On Jun 22, 2009, at 10:28 AM, Andrew Premdas 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
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Hey Andrew,
I don't think there is a known convention for this. If I only use the macro for a single set of examples then I leave the macro code inline with the actual examples. Once I need it in multiple files then I will move it to my root spec dir. I suppose you could create a spec/ macros dir if you want (this would make it easier to require all of the ones you have). I generally don't have a whole lot so I just put my macros and matchers under spec/ and let spec_helper require them. Then in your spec helper if you want all of your examples to have access to these macros you can say:

Spec::Runner.configure do |config|
  config.extend(MyMacro, MyOtherMacro)
end

HTH,
Ben
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to