当我运行rspec测试时,我得到:
/home/jasiek/Desktop/katowice-ror-workshops-2015/spec/support/features.rb:2:in阻止':未初始化的常量功能(NameError)
我认为问题仅出现在我的本地计算机上,因为这是来自信任源的回购(另一个用户没有遇到此问题)。我正在谈论的回购:https://github.com/netguru-training/katowice-ror-workshops-2015
我在Stack上看到问题可能会遗漏:
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
但我已经明白了。
哪里可能有问题?
这是来自控制台的整个日志:
jasiek @ jasiek-HP-EliteBook-8470p:〜/ Desktop / katowice-ror-workshops-2015 $ RAILS_ENV = test bundle exec rspec /home/jasiek/Desktop/katowice-ror-workshops-2015/spec/support/features.rb:2:in
block in <top (required)>': uninitialized constant Features (NameError) from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core.rb:97:in
configure&#39; 来自/home/jasiek/Desktop/katowice-ror-workshops-2015/spec/support/features.rb:1:in<top (required)>' from /home/jasiek/Desktop/katowice-ror-workshops-2015/spec/rails_helper.rb:23:in
阻止&#39; 来自/home/jasiek/Desktop/katowice-ror-workshops-2015/spec/rails_helper.rb:23:ineach' from /home/jasiek/Desktop/katowice-ror-workshops-2015/spec/rails_helper.rb:23:in
&#39; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:inrequire' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
阻止要求=&#39; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:ineach' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration.rb:1280:in
要求=& #39; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:109:inblock in process_options_into' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:in
每个&#39 ; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:108:inprocess_options_into' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/configuration_options.rb:21:in
configure&#39 ; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:101:insetup' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:88:in
run&#39 ; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:73:inrun' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/lib/rspec/core/runner.rb:41:in
调用&#39 ; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/gems/rspec-core-3.3.0/exe/rspec:4:in<top (required)>' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/bin/rspec:23:in
loading&#39; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/bin/rspec:23:in<main>' from /home/jasiek/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in
eval&#39; 来自/home/jasiek/.rvm/gems/ruby-2.2.0-preview1/bin/ruby_executable_hooks:15:in`&#39;
答案 0 :(得分:1)
尝试在spec/support/features.rb
文件中添加以下内容:
require '../../spec/support/features/session_helpers'
所以,它变成了:
require '../../spec/support/features/session_helpers'
RSpec.configure do |config|
config.include Features::SessionHelpers, type: :feature
end
答案 1 :(得分:0)
我知道它迟到了。
但对于其他可能来这里寻找答案的人。我面临同样的问题。
所以,当我在规范中检查rails_helper.rb
文件时,我发现了这一行
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
最初被评论,所以我没有评论它,一切正常。 我正在使用
gem 'capybara', '~> 2.15', '>= 2.15.4'
gem 'rspec-rails', '~> 3.6'