当前位置:  开发笔记 > 后端 > 正文

RSpec:无法加载此类文件 - teamcity/spec/runner/formatter/teamcity/formatter(LoadError)

如何解决《RSpec:无法加载此类文件-teamcity/spec/runner/formatter/teamcity/formatter(LoadError)》经验,为你挑选了1个好方法。

此解决方案不适用于我:

在RubyMine中运行规范会导致"无法加载此类文件 - teamcity/spec/runner/formatter/teamcity/formatter(LoadError)"

以及这篇文章:

https://www.jetbrains.com/ruby/help/using-rspec-in-rails-applications.html

我使用的是Ubuntu 15.10,RubyMine 7.1,Ruby 2.2.3,Rails 4.2.5

当我试图启动RSpec时,Run 'spec:project它返回一个错误:

/home/duke/.rvm/rubies/ruby-2.2.3/bin/ruby -I/home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib:/home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-support-3.4.1/lib /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
/home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `require': cannot load such file -- teamcity/spec/runner/formatter/teamcity/formatter (LoadError)
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires='
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires='
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
    from /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/exe/rspec:4:in `
' /home/duke/.rvm/rubies/ruby-2.2.3/bin/ruby -I/home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/lib:/home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-support-3.4.1/lib /home/duke/.rvm/gems/ruby-2.2.3/gems/rspec-core-3.4.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed Process finished with exit code 1

同时,如果我$ bundle exec rspec在终端中运行,输出是:

No examples found.


Finished in 0.00029 seconds (files took 2.21 seconds to load)
0 examples, 0 failures

我是测试的新手,所以这对我来说都很奇怪.

UPD: .rspec很空

--color
--require spec_helper

我的spec文件夹:

.
??? lib
?   ??? destroy_user_spec.rb
??? rails_helper.rb
??? spec_helper.rb

在Gemfile中我添加了:

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'rspec-rails'
  #gem 'factory_girl'
  #gem 'ffaker'
  #gem 'shoulda-matchers'
  #gem 'pry-byebug'
end

跑了bundle install,所以安装了宝石.

UPD2:如果我正在运行' 'destroy_user_spec.rb''直接运行规范,我的测试工作正常.



1> Viktor..:

解决了:之后我不得不重新启动Rubymine rails g rspec:install


这是[与Spring预加载器和RubyMine相关的问题]的重复版本(http://stackoverflow.com/questions/24525945/running-a-spec-in-rubymine-results-in-cannot-load-such-file -teamcity-spec-ru),[这是实际修复](http://stackoverflow.com/a/36757377/25192),而不是上面接受的答案.
推荐阅读
可爱的天使keven_464
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有