我有一个gem并且最近将cucumber-rails
添加到.gemspec:
spec.add_development_dependency "cucumber-rails", "~> 1.4.3"
现在,当我用rake build
打包gem时,我收到以下消息:
WARNING: Cucumber-rails required outside of env.rb. The rest of loading is being deferred
until env.rb is called. To avoid this warning, move 'gem 'cucumber-rails',
:require => false' under only group :test in your Gemfile. If already
in the :test group, be sure you are specifying ':require => false'.
让这种情况消失的最佳方法是什么?我应该将cucumber-rails
添加到gem的Gemfile而不是.gemspec吗?
答案 0 :(得分:1)
如果其他人遇到此问题,以下内容对我有用:
将其添加为gem的Gemfile中的依赖项。我的Gemfile目前看起来像这样:
source 'https://rubygems.org'
gemspec
gem "cucumber-rails", "~> 1.4.3", require: false, group: :test
这会在运行rake build
时消失。我发布gem并将其添加到Rails应用程序时可能会出现问题。我发现后,我会更新我的解决方案。
更新:我尝试打包gem并将其加载到主机应用程序中。一切都很好看。