Helpers for examples?


#1

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.

Thx,

dwh


#2

On Fri, May 15, 2009 at 9:04 AM, Denis H. removed_email_address@domain.invalid
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/.

Thx,

dwh


rspec-users mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/rspec-users


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


#3

On Fri, May 15, 2009 at 12:29 PM, Zach D. removed_email_address@domain.invalid
wrote:

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
end


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


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


#4

I was just about to ask that. Thanks!

dwh