2

I am trying to use a Rails engine in my rails application.

The rails engine uses a gem called spin.js.

In my rails app, I have in my spec_helper file, this code to include the engine (which is a gem).

require 'mycustomEngine'

When I run rspec I get this error:

C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/spinjs-rails-1.4/lib/spinjs
-rails/engine.rb:2:in `<module:Spinjs>': uninitialized constant Rails (NameError
)
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/spinjs-rails-1
.4/lib/spinjs-rails/engine.rb:1:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/spinjs-rails-1

Any ideas why?

1
  • Did you solve that problem? Commented May 31, 2017 at 20:00

1 Answer 1

3

Depending on how you have your rails_helper / spec_helper configured, you might be requiring the engine (or some other dependency) that tries to access the Rails constant, which doesn't get loaded until you get to the line require File.expand_path('../../config/environment', __FILE__). Try requiring it after that?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.