KSL
KSL

Reputation: 49

Include helper module in Capybara specs

I am writing specs for Capyabara in rails. Here i found article to share common code between the feature specs. link : http://robots.thoughtbot.com/rspec-integration-tests-with-capybara

But when I use its module method 'sign_in' in my rails spec it's giving error "uninitialized constant sign_in'"

describe "GET /" do
  ## include Features::SessionHelpers

  before :each do
    sign_in
  end
     ....

How can I import this helper module in my rspec correctly? thanks.

Upvotes: 0

Views: 1322

Answers (1)

Justin Ko
Justin Ko

Reputation: 46826

The helper methods can be included using RSpec.configure.

Assuming you want the helper methods available to all examples, add the following to your spec helper (or at least somewhere outside the example group):

RSpec.configure do |c|
  c.include Features::SessionHelpers
end

For more examples, such as only adding the helper methods to specific examples, see the Relish's helper method page.

Upvotes: 1

Related Questions