[rspec-users] preferred place for methods used by both rspec and cucumber?

David Chelimsky dchelimsky at gmail.com
Thu Sep 22 01:29:41 EDT 2011


On Sep 22, 2011, at 4:35 AM, Patrick J. Collins wrote:

> Hi,
> 
> I have some helper methods such as:
> 
> def mock_omniauth
>  OmniAuth.config.test_mode = true
>  OmniAuth.config.mock_auth[:facebook] = facebook_user
> end
> 
> def facebook_user
>  @facebook_user ||= HashWithIndifferentAccess.new(YAML.load(File.read("#{Rails.root}/test/fixtures/fb_user.yml")))
> end
> 
> that I want to use in both cucumber step definitions and rspec.  Is there a
> preferred place to store this code,

This doesn't come up that often so there is no established convention. I've put such code in files in spec/support and included it from the features directory before. I'm sure the other way round would work just fine.

> or is it standard practice to just define
> them in a module in config/inititalizers and include that in both cucumber's
> env.rb and rspec's spec_helper.rb?

config/initializers is about application initialization IMO, so I wouldn't put this material there.

Anybody else?

David


More information about the rspec-users mailing list