Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.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
Ruby on rails 使用警卫和咆哮运行rspec时出错_Ruby On Rails_Rspec Rails_Guard_Spork_Growl - Fatal编程技术网

Ruby on rails 使用警卫和咆哮运行rspec时出错

Ruby on rails 使用警卫和咆哮运行rspec时出错,ruby-on-rails,rspec-rails,guard,spork,growl,Ruby On Rails,Rspec Rails,Guard,Spork,Growl,我是一名高中生,刚接触RubyonRails,正在尝试用TDD开发Rails4应用程序。我将guard与rspec、spork和growl通知一起使用,但是当我运行guard运行测试时,我得到以下输出,并且测试没有结果: 11 clairehuang:mezzo$ guard 18:23:31 - INFO - Guard is using GrowlNotify to send notifications. 18:23:31 - INFO - Guard is using TerminalTi

我是一名高中生,刚接触RubyonRails,正在尝试用TDD开发Rails4应用程序。我将guard与rspec、spork和growl通知一起使用,但是当我运行guard运行测试时,我得到以下输出,并且测试没有结果:

11 clairehuang:mezzo$ guard
18:23:31 - INFO - Guard is using GrowlNotify to send notifications.
18:23:31 - INFO - Guard is using TerminalTitle to send notifications.
18:23:31 - INFO - Starting Spork for RSpec
Using RSpec, Unknown
Loading Spork.prefork block...
Spork is ready and listening on 8989!
18:23:33 - INFO - Spork server for RSpec successfully started

18:23:33 - INFO - LiveReload is waiting for a browser to connect.
18:23:33 - INFO - Guard::RSpec is running
18:23:33 - INFO - Running all specs
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/growl_notify-0.0.3/lib/growl_notify.rb:53: warning: instance variable @icon not initialized

18:23:34 - INFO - Guard is now watching at '/Users/clairehuang/Sites/mezzo'
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:76: warning: global variable `$CELLULOID_DEBUG' not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/guard-2.6.1/lib/guard/interactor.rb:64: warning: instance variable @enabled not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/guard-2.6.1/lib/guard/interactor.rb:129: warning: instance variable @thread not initialized
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/pry-0.10.0/lib/pry/method.rb:383: warning: instance variable @method not initialized
[1] guard(main)>
如果我只独立于guard运行rspec,我的测试运行正常并显示输出:

13 clairehuang:mezzo$ rspec
/Users/clairehuang/.rvm/gems/ruby-1.9.3-p448/gems/spork-1.0.0rc4/lib/spork.rb:83: warning: assigned but unused variable - method_name_with_spork
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
F

Failures:

  1) Donations GET /donations should display some donations
     Failure/Error: visit donations_path
     NameError:
       undefined local variable or method `donations_path' for #<RSpec::ExampleGroups::Donations::GETDonations:0x007ffd038e5118>
     # ./spec/requests/donations_spec.rb:6:in `block (3 levels) in <top (required)>'

Deprecation Warnings:

RSpec::Core::Configuration#treat_symbols_as_metadata_keys_with_true_values= is deprecated, it is now set to true as default and setting it to false has no effect.


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

1 deprecation warning total

Finished in 0.00081 seconds (files took 0.20421 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/requests/donations_spec.rb:5 # Donations GET /donations should display some donations

看看这里的答案:看看它是否对你有帮助。@Tarynest:谢谢!所有警告现在都消失了,但rspec不会打印任何输出。还有什么我需要更改的吗?您希望看到什么输出?你知道guard只在更新文件时运行,对吗?我假设您尝试编辑某个文件并保存了它…是的,当我更新测试文件并保存它时,测试将运行,但不会显示“Running:spec/requests/investments\u spec.rb”以外的输出,并且咆哮会说rspec结果失败。确定。。。恐怕我帮不上忙了。
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch('config/environments/test.rb')
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb') { :rspec }
  watch('test/test_helper.rb') { :test_unit }
  watch(%r{features/support/}) { :cucumber }
end

guard 'livereload' do
  watch(%r{app/views/.+\.(erb|haml|slim)$})
  watch(%r{app/helpers/.+\.rb})
  watch(%r{public/.+\.(css|js|html)})
  watch(%r{config/locales/.+\.yml})
  # Rails Assets Pipeline
  watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/assets/#{m[3]}" }
end

guard :rspec, :all_on_start => true, :cmd => "--drb" do
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
  watch('spec/spec_helper.rb')  { "spec" }

  # Rails example
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$})          { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
  watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }

  # Capybara features specs
  watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$})     { |m| "spec/features/#{m[1]}_spec.rb" }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end