Search code examples
ruby-on-rails-3rspec

Where am I supposed to put my rspec helpers?


I would like to write a helper that will only be used in my spec files and I do not know where this code should go.

I am not trying to test an app helper and I do not feel like creating an app helper that will only be used for testing.

What is the good practice?


Solution

  • Typically I put these in spec/support/spec_helpers. I then include those modules in the appropriate examples.

    If you have some that are useful to all specs of a certain type (e.g. all request specs) then you can do

    config.include SomeHelper, :type => :request
    

    which will include that module into all your request example groups.