Question

When I run 'rspec' or 'bundle exec rspec' it doesn't let me use the dependencies in my .gemspec file. Do I have to repeat myself and break the DRY principle and display my gems in Gemfile and .gemspec?? (ps. I am doing this for my models files as a rails engine)

Gemfile:

gemspec

.gemspec:

  s.add_dependency "rails", "~> 3.2.13"
  s.add_dependency "mongoid"
  s.add_dependency "mongoid_commentable"

Example:

"bundle exec rspec" Displays errors:

uninitialized constant Mongoid::Commentable
uninitialized constant Comment::Mongoid_Commentable
uninitialized constant Mongoid::Commentable
Was it helpful?

Solution

Gem dependencies are not autoloaded as opposed to using Bundler/Gemfile. Thus, you'll have to require the gems that you depend upon.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top