Jensky
Jensky

Reputation: 917

Cannot load session_helpers from RSpec

When I run RSpec tests I get:

/home/jasiekm/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- ../../spec/support/features/session_helpers (LoadError)

My repo is just cloned from here.

I want to add manual require because I have problem similar to this.

What is the problem with my require?

My features.rb file:

require '../../spec/support/features/session_helpers'

RSpec.configure do |config|
  config.include Features::SessionHelpers, type: :feature
end

I just want to include this specific session_helpers.rb file and that's all.

EDIT: but when I paste code from session_helpers.rb manually everything works. But I suppose it isn't elegant way.

Upvotes: 1

Views: 84

Answers (2)

Jensky
Jensky

Reputation: 917

I found the solution. Just add this line to spec_helper.rb file (not features.rb):

require 'support/features/session_helpers'

Upvotes: 0

TK-421
TK-421

Reputation: 10763

It's relative to rspec, most likely (the current working directory).

Check out the solution suggested here:

Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

Upvotes: 1

Related Questions