[rspec-users] helpers for examples?

Zach Dennis zach.dennis at gmail.com
Fri May 15 12:30:55 EDT 2009

On Fri, May 15, 2009 at 12:29 PM, Zach Dennis <zach.dennis at gmail.com> wrote:
> On Fri, May 15, 2009 at 9:04 AM, Denis Haskin <denis at haskinferguson.net> wrote:
>> Where's the recommended place to put helper methods & etc for examples?
>> I've started putting them in spec/spec_helper.rb but that's going to get
>> awfully cluttered.  I'm thinking maybe a spec/lib, and add that to include
>> path?  Or just put them in lib?  I notice restful_authentication (I think)
>> put AuthenticatedTestHelper there.
> I make a spec/spec_helpers/ directory and put them in there. I try to
> namespace them in the module SpecHelpers to avoid conflict and/or
> confusion with other modules in the app.
> I would not use spec/lib/, because a rails app has a lib directory,
> and convention would have someone assume spec/lib/ are specs for
> objects in RAILS_ROOT/lib/.

Forgot to add in my spec_helper.rb I load all ruby files in spec/spec_helpers/

   Dir[File.dirname(__FILE__) + '/spec_helpers/**/*.rb'].each { |f require f }

and then in my spec config I include specific ones I need:

Spec::Runner.configure do |config|
  config.include SpecHelpers::MyApplicationMatchers
  config.include SpecHelpers::ControllerMacros, :type => :controller

>> Thx,
>> dwh
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
> --
> Zach Dennis
> http://www.continuousthinking.com (personal)
> http://www.mutuallyhuman.com (hire me)
> @zachdennis (twitter)

Zach Dennis
http://www.continuousthinking.com (personal)
http://www.mutuallyhuman.com (hire me)
@zachdennis (twitter)

More information about the rspec-users mailing list