ChrisCPO
ChrisCPO

Reputation: 463

Rails how to configure rspec so you do not need to require "rails_helper"

title says it all mostly. Given new Rails app and rspec-rails. If I app an app/lib/foo.rb class. How do I configure rspec to be loaded so I do not have to do this:

# spec/lib/foo_spec.rb
require "rails_helper"

describe Foo do
end

Upvotes: 2

Views: 983

Answers (2)

Kyryl Ωliinyk
Kyryl Ωliinyk

Reputation: 146

Just type in your terminal(project root folder):

echo --require rails_helper > .rspec

Upvotes: 0

SJTalbutt
SJTalbutt

Reputation: 31

In the .rspec file at the root of the project, add

--require rspec_helper

on its own line. The rspec command adds any options in this file automatically when run.

Upvotes: 3

Related Questions