0

我是 Rails 和 Guard 的新手,我正在观看一个截屏视频,它似乎输出了错误、示例等的数量。但是,当我运行它时,我收到以下输出:

    18:31:11 - INFO - Running: spec/controllers/tasks_controller_spec.rb
/Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit/testcase.rb:9:in `<class:TestCase>': uninitialized constant Test::Unit::TestCase::Assertions (NameError)
    from /Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit/testcase.rb:8:in `<module:Unit>'
    from /Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit/testcase.rb:4:in `<module:Test>'
    from /Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit/testcase.rb:3:in `<top (required)>'
    from /Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit.rb:5:in `<top (required)>'
    from /Users/Phil/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/test/unit/assertions.rb:4:in `<top (required)>'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-rails-2.14.0/lib/rspec/rails/adapters.rb:3:in `<top (required)>'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-rails-2.14.0/lib/rspec/rails.rb:11:in `<top (required)>'
    from /Users/Phil/rails/tasks/spec/spec_helper.rb:4:in `<top (required)>'
    from /Users/Phil/rails/tasks/spec/controllers/tasks_controller_spec.rb:1:in `require'
    from /Users/Phil/rails/tasks/spec/controllers/tasks_controller_spec.rb:1:in `<top (required)>'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in `load'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in `each'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/configuration.rb:896:in `load_spec_files'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/runner.rb:80:in `run'
    from /Users/Phil/.rvm/gems/ruby-1.9.3-p448/gems/rspec-core-2.14.3/lib/rspec/core/runner.rb:17:in `block in autorun'

难道我做错了什么?

4

3 回答 3

1

事实证明,至少在我的情况下,我不得不移除 gem 'turns' 并且修复了整个事情。

于 2013-07-20T23:39:30.353 回答
0

您会看到 rspec 处理您的规范文件的输出,这是正常的。如果您的规范运行无异常,那么您只会看到成功/失败报告。但是,如果您的规范引发错误,那么您将获得堆栈跟踪,正如您在本例中看到的那样。您应该查看跟踪并确定您的规范和/或应用程序代码中可能存在错误的位置。

于 2013-07-20T23:06:09.190 回答
0

在您的堆栈跟踪(您发布的所有行)中,您得到了问题的答案。

查找指向项目中文件的行,这些行以路径“/Users/Phil/rails/”开头

第一个指向“/Users/Phil/rails/tasks/spec/controllers/tasks_controller_spec.rb”第 1 行,似乎抱怨 require 语句。这就是你应该开始调查的地方。

这是测试的基本原则:遇到错误,找到它的位置,然后找到它的原因,最后修复它:)

祝你好运

于 2013-07-20T23:10:15.920 回答