1

我正在 laravel 4 中创建一个应用程序/站点。我正在使用 laravel-guard 设置 Laravel,这有助于真正轻松地构建资产并创建模块化设置,以便您可以快速缩小 css 和 js。

我在这里按预期运行所有内容

我已经运行了正确的 ruby​​ 版本等,这很酷。

当我运行命令php artisan guard:make时它工作得很好但是当我尝试运行时

php artisan guard:watch

我在那里遇到了一些非常奇怪的错误,它们根本无法正常工作。

我得到的错误是:

17:21:54 - ERROR - Could not load 'guard/phpunit' or find class Guard::Phpunit
17:21:54 - ERROR - /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts'
> [#] /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `activate'
> [#] /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems.rb:212:in `rescue in try_activate'
> [#] /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems.rb:209:in `try_activate'
> [#] /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
> [#] /Users/mdunbavan/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/plugin_util.rb:100:in `plugin_class'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/plugin_util.rb:57:in `initialize_plugin'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard.rb:167:in `add_plugin'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/dsl.rb:166:in `guard'
> [#] /Freelance/Current Projects/knight-dragon/knightdragon/Guardfile:12:in `_instance_eval_guardfile'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/guardfile/evaluator.rb:121:in `instance_eval'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/guardfile/evaluator.rb:121:in `_instance_eval_guardfile'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/guardfile/evaluator.rb:37:in `evaluate_guardfile'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/setuper.rb:144:in `evaluate_guardfile'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/setuper.rb:62:in `setup'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/commander.rb:24:in `start'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/lib/guard/cli.rb:96:in `start'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/gems/guard-2.2.1/bin/guard:6:in `<top (required)>'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/bin/guard:19:in `load'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/bin/guard:19:in `<main>'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
> [#] /Users/mdunbavan/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
17:21:54 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `superclass' for nil:NilClass

这是我的宝石列表中的内容:

guard (2.2.1, 1.4.0)
guard-coffeescript (1.3.4)
guard-concat (0.0.3)
guard-livereload (2.0.0)
guard-phpunit (0.1.4)
guard-sass (1.3.2)

我查看了我的宝石清单,它似乎在那里,所以我根本无法弄清楚。

有谁知道为什么会发生这种情况?

4

2 回答 2

3

有一个与 Guard::PHPUnit 相关的问题,我也无法让它工作。如果您不需要 PHPUnit,一个解决方法:编辑您的 Guardfile 并注释此块:

#guard :phpunit, :all_on_start => false, :tests_path => 'app/tests/', :cli => '--colors -c phpunit.xml', :require => false do
#  # Run any test in app/tests upon save.
#  watch(%r{^.+Test\.php$})
#
#  # When a view file is updated, run tests.
#  # Tip: you probably only want to run your integration tests.
#  watch(%r{app/views/.+\.php}) { Dir.glob('app/tests/**/*.php') }
#
#  # When a file is edited, try to run its associated test.
#  # Save app/models/User.php, and it will run app/tests/models/UserTest.php
#  watch(%r{^app/(.+)/(.+)\.php$}) { |m| "app/tests/#{m[1]}/#{m[2]}Test.php"}
#end

现在它应该可以工作了,但是 PHPUnit 将被禁用:

php artisan guard:watch
于 2013-10-23T17:54:20.520 回答
0

须藤宝石安装守卫-phpunit2

并编辑:phpunit -> phpunit2

guard :phpunit2, :all_on_start => false, :tests_path => 'app/tests/', :cli => '--colors -c phpunit.xml' do
  # Run any test in app/tests upon save.
  watch(%r{^.+Test\.php$})

  # When a view file is updated, run tests.
  # Tip: you probably only want to run your integration tests.
  watch(%r{app/views/.+\.php}) { Dir.glob('app/tests/**/*.php') }

  # When a file is edited, try to run its associated test.
  # Save app/models/User.php, and it will run app/tests/models/UserTest.php
  watch(%r{^app/(.+)/(.+)\.php$}) { |m| "app/tests/#{m[1]}/#{m[2]}Test.php"}
end
于 2014-08-05T09:01:04.853 回答