Forum: RSpec helpers for examples?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Denis H. (Guest)
on 2009-05-15 17:19
(Received via mailing list)
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
Zach D. (Guest)
on 2009-05-15 21:01
(Received via mailing list)
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)
Zach D. (Guest)
on 2009-05-15 21:15
(Received via mailing list)
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)
Denis H. (Guest)
on 2009-05-15 21:38
(Received via mailing list)
<grin>  I was just about to ask that.  Thanks!

dwh
This topic is locked and can not be replied to.