Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让rspec读取gempec中的依赖项?_Rspec_Gemspecs - Fatal编程技术网

如何让rspec读取gempec中的依赖项?

如何让rspec读取gempec中的依赖项?,rspec,gemspecs,Rspec,Gemspecs,当我运行“rspec”或“bundle exec rspec”时,它不允许我使用.gempec文件中的依赖项。我必须重复我自己,打破干燥的原则,在Gemfile和.gempec中显示我的宝石吗??(顺便说一句,我是作为rails引擎为我的模型文件这样做的) 档案: gemspec .GEMPEC: s.add_dependency "rails", "~> 3.2.13" s.add_dependency "mongoid" s.add_dependency "mongoid

当我运行“rspec”或“bundle exec rspec”时,它不允许我使用.gempec文件中的依赖项。我必须重复我自己,打破干燥的原则,在Gemfile和.gempec中显示我的宝石吗??(顺便说一句,我是作为rails引擎为我的模型文件这样做的)

档案:

gemspec
.GEMPEC:

  s.add_dependency "rails", "~> 3.2.13"
  s.add_dependency "mongoid"
  s.add_dependency "mongoid_commentable"
例如:

“bundle exec rspec” 显示错误:

uninitialized constant Mongoid::Commentable
uninitialized constant Comment::Mongoid_Commentable
uninitialized constant Mongoid::Commentable

与使用Bundler/Gemfile相反,Gem依赖项不会自动加载。因此,您必须
要求
您所依赖的gem。

在spec\u helper.rb中,您通常在哪里自动加载这些gem?通常您在spec\u helper中加载gem。您的gem应该在其主文件中加载其依赖项。