使用带有rspec的guard时出错

时间:2012-07-30 04:17:01

标签: ruby-on-rails rspec

我正在跟踪http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/?search_index=2

的“导视屏幕截图 - 我希望我有的教程”

基于此,我将以下宝石添加到我的文件中 -

group :test, :development do 
  gem 'turn'
  gem 'rspec-rails'
  gem 'capybara'
  gem 'guard-rspec'
  gem 'libnotify'
end

我跑了以下命令 -

rails g rspec:install
guard init rspec
guard

我在跑卫时遇到以下错误。我应该看到失败的测试。我已经生成了集成测试 -

  

守护在这里!看起来你的项目有一个Gemfile,但你是   在Bundler之外运行guard。如果这是你的意图,请随意   忽略此消息。否则,请考虑使用bundle exec guard   确保正确加载依赖项。 (你可以运行guard   使用--no-bundler-warning来消除此消息。)

     

Guard使用Libnotify发送通知。警卫正在看着   '/ home / murtaza / workspace / rails / tasks'Guard :: RSpec正在运行,有   RSpec 2!运行所有规格gem install minitest   /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:9:in   来自<class:TestCase>': uninitialized constant Test::Unit::TestCase::Assertions (NameError) from /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:8:in '   /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:4:in   来自<module:Test>' from /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/testcase.rb:3:in '   /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:5:in   来自<top (required)>' from /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit/assertions.rb:4:in '   /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-2.11.0/lib/rspec/rails/adapters.rb:2:in   来自<top (required)>' from /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-2.11.0/lib/rspec/rails.rb:10:in '   /home/murtaza/workspace/rails/tasks/spec/spec_helper.rb:4:in <top (required)>' from /home/murtaza/workspace/rails/tasks/spec/requests/tasks_spec.rb:1:in 要求'来自   /home/murtaza/workspace/rails/tasks/spec/requests/tasks_spec.rb:1:in   来自<top (required)>' from /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in加载'   /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in block in load_spec_files' from /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in map'from   /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in load_spec_files' from /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in run'from   /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in   run' from /home/murtaza/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in 阻止自动运行'   &GT;

2 个答案:

答案 0 :(得分:1)

问题在于'转'宝石。删除它可以解决问题。

https://github.com/rspec/rspec-rails/issues/484

答案 1 :(得分:1)

尝试运行bundle exec guard作为最终命令,而不是运行guard

命令的bundle exec部分告诉后卫在通过Bundler加载的宝石中运行。 Bundler是一个允许本地文件夹拥有自己的gem环境的工具。

这是错误消息所指示的内容:

  

守护在这里!看起来你的项目有一个Gemfile,但是你在Bundler之外运行守卫。如果这是您的意图,请随时忽略此消息。否则,请考虑使用bundle exec guard来确保正确加载依赖项。 (您可以使用--no-bundler-warning运行警卫以消除此消息。)