Fleeck
Fleeck

Reputation: 1066

Ruby On Rails Rspec 'require' doesn't find the file

File system looks like this:

File system

page_spec.rb:

require 'rails_helper'
  RSpec.describe Page, type: :model do
    ...
  end

rails_helper.rb's require part:

require 'spec_helper'

When I try to run rspec page_spec.rb it says that "cannot load such file rails_helper". When i change to require '../rails_helper', it says "Cannot load spec_helper". How can I fix this?

Upvotes: 1

Views: 1153

Answers (2)

smita
smita

Reputation: 36

Change the line require 'rails_helper'in page_spec.rb file to require_relative '../rails_helper'.

Upvotes: 1

Khushkaran Singh
Khushkaran Singh

Reputation: 79

Run the rspec command from the root directory rspec spec/models/page_spec.rb

Upvotes: 1

Related Questions