RSPEC失败/错误:无法从回溯中找到匹配的行

时间:2014-12-17 18:25:05

标签: ruby-on-rails-4 rspec

我很难过。我不确定如何找到问题的根源。这是我得到的错误:

> bundle exec rspec spec 

ThemeMaintainer
  should have tests (FAILED - 1)

Failures:

  1) ThemeMaintainer should have tests
     Failure/Error: Unable to find matching line from backtrace
     TypeError:
       wrong argument type Class (expected Module)
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `include'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `block in add_template_helper'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `module_eval'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `add_template_helper'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:95:in `block in helper'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:94:in `each'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:94:in `helper'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/action_view/test_case.rb:93:in `include_helper_modules!'
     # /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/action_view/test_case.rb:86:in `new'

Finished in 0.0017 seconds (files took 13.66 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/helpers/theme_maintainer_spec.rb:4 # ThemeMaintainer should have tests

Top 1 slowest examples (0.00001 seconds, 0.8% of total time):
  ThemeMaintainer should have tests
    0.00001 seconds ./spec/helpers/theme_maintainer_spec.rb:4

Randomized with seed 27022

Coverage report generated for RSpec to /Users/tj/projects/AOT/aotv2/coverage. 9272 / 22617 LOC (41.0%) covered.
/Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `include': wrong argument type Class (expected Module) (TypeError)
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `block in add_template_helper'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `module_eval'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:170:in `add_template_helper'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:95:in `block in helper'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:94:in `each'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/abstract_controller/helpers.rb:94:in `helper'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/action_view/test_case.rb:93:in `include_helper_modules!'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/actionpack-4.0.12/lib/action_view/test_case.rb:86:in `new'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/example_group.rb:472:in `run'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block (2 levels) in run_specs'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `map'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:111:in `block in run_specs'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/reporter.rb:53:in `report'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:107:in `run_specs'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:85:in `run'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:69:in `run'
    from /Users/tj/.rvm/rubies/ruby-2.1.3/lib/ruby/gems/2.1.0/ruby/2.1.0/gems/rspec-core-3.1.4/lib/rspec/core/runner.rb:37:in `invoke'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/gems/rspec-core-3.1.4/exe/rspec:4:in `<top (required)>'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/bin/rspec:23:in `load'
    from /Users/tj/.rvm/gems/ruby-2.1.3@global/ruby/2.1.0/bin/rspec:23:in `<main>'

这是规范

require 'spec_helper.rb'

RSpec.describe ThemeMaintainer do
  it 'should have tests'

end

每次我运行rspec spec我都会立即得到一个不同规范的错误(它是随机化的测试序列)。明显? ThemeMaintainer规范没有任何问题。每一个我得到错误的人都可以在自己运行时轻松通过。

所以我的问题是如何找到真正失败的规范?

根据规格,我有8个目录。我运行它们rspec spec/<dir> 8次单独运行,所有运行正常。只有当我为整个应用程序运行rspec spec时才会收到错误消息。 Stacktrace总是一样的。错误总是一样的。

我可以使用一些如何诊断的指导。

2 个答案:

答案 0 :(得分:0)

显然,正如Github问题响应中所建议的那样,不应该使用config.infer_spec_type_from_file_location!(在RSpec.configure中将其关闭)并解决问题。

我仍然不确定为什么已经使用它2年并且到目前为止没有任何问题它现在失败了。

答案 1 :(得分:-2)

你没有关闭该区块。

require 'spec_helper.rb'

RSpec.describe ThemeMaintainer do
  it 'should have tests' do
  end
end