Rails:SimpleCov 失败,出口 1 - 如何解决这个问题
Rails: SimpleCov failed with exit 1 - how to solve this
我正在将 rails 应用程序从 rails 4.2
升级到 5.0
。然后,进入 5.1
、5.2
。它正在使用 ruby 2.6.4
.
当我 运行 我的规格测试时,我收到错误:SimpleCov failed with exit 1
。我无法使用 Google 找到任何特定于此的信息。我已经通读了 gem 的文档,但我找不到任何信息可以帮助我了解导致此问题的原因或解决方法。
Gemfile:
gem 'rails', '~> 5.0'
我还在 Gemfile 中进行了这些更改以使 bundle update rails
正常工作。
-gem 'sass-rails', '~> 4.0.3'
+gem 'sass-rails'
-gem 'coffee-rails', '~> 4.0.0'
+gem 'coffee-rails'
Gemfile.lock (shows)
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
我没有在我的 Gemfile 中列出 simplecov-html
,所以我不明白为什么 Gemfile.lock 将 gem 显示为 0.11
和 0.12.2
。这是个问题吗?
为了消除几个不相关的弃用警告,我不得不对这些文件进行更改。复制自 git diff
在这里注明,以防万一...
config/environments/production.rb
- config.serve_static_files = false
+ config.public_file_server.enabled = false
config/environments/staging.rb
- config.serve_static_files = false
+ config.public_file_server.enabled = false
config/environments/test.rb
- config.serve_static_files = true
+ config.public_file_server.enabled = true
- config.static_cache_control = "public, max-age=3600"
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
运行 规范测试
jdc44@dev:~/apps/ereqs$ bundle exec rake
...
Coverage report generated for RSpec to /home/STATLER/jdc44/apps/ereqs/coverage. 3 / 892 LOC (0.34%) covered.
SimpleCov failed with exit 1
Traceback (most recent call last):
30: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/exe/rspec:4:in `<main>'
29: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:45:in `invoke'
28: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:71:in `run'
27: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:86:in `run'
26: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:100:in `setup'
25: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
24: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1433:in `each'
23: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
22: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1435:in `load'
21: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `<top (required)>'
20: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `require'
19: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `<top (required)>'
18: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `require'
17: from /home/STATLER/jdc44/apps/ereqs/config/environment.rb:5:in `<top (required)>'
16: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
15: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
14: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
13: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
12: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
11: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
10: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
9: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `call'
8: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `each'
7: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
6: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
5: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
4: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
3: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
2: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
1: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
/home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:105:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need
to be rendered by your app:
Example:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
and restart your server
我不认为 manifest.js 输出是相关的,但保留它以防万一它是任何人的线索。
第 18 - 21 行包括我们编写的两个文件(不是由 ruby/rails 创建的)。
21: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `<top (required)>'
20: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `require'
19: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `<top (required)>'
18: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `require'
spec/controllers/admins/account_codes_controller_spec.rb (with line nbr)
1 require 'spec_helper'
spec/spec_helper.rb (with line nbrs)
1 require 'simplecov'
2 SimpleCov.start 'rails'
3
4 # This file is copied to spec/ when you run 'rails generate rspec:install'
5 ENV["RAILS_ENV"] ||= 'test'
6 require File.expand_path("../../config/environment", __FILE__)
7 require 'rspec/rails'
8 require 'capybara/rspec'
9 require 'webmock/rspec'
10 require 'statlerwire/spec_helpers'
我不知道任何可能包含任何线索的日志文件。我通过 Google 阅读了很多主题,但没有找到与我的实际主题相关的主题。
如有任何帮助,我们将不胜感激。
约翰·C
因为 simplecov
仍然出现在您的 Gemfile.lock
文件中,您最好的操作是删除 Gemfile.lock
文件,然后 运行 bundle install
。这将重新创建您的 Gemfile.lock
文件并且 simplecov
应该消失。
我正在将 rails 应用程序从 rails 4.2
升级到 5.0
。然后,进入 5.1
、5.2
。它正在使用 ruby 2.6.4
.
当我 运行 我的规格测试时,我收到错误:SimpleCov failed with exit 1
。我无法使用 Google 找到任何特定于此的信息。我已经通读了 gem 的文档,但我找不到任何信息可以帮助我了解导致此问题的原因或解决方法。
Gemfile:
gem 'rails', '~> 5.0'
我还在 Gemfile 中进行了这些更改以使 bundle update rails
正常工作。
-gem 'sass-rails', '~> 4.0.3'
+gem 'sass-rails'
-gem 'coffee-rails', '~> 4.0.0'
+gem 'coffee-rails'
Gemfile.lock (shows)
simplecov (0.18.5)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
我没有在我的 Gemfile 中列出 simplecov-html
,所以我不明白为什么 Gemfile.lock 将 gem 显示为 0.11
和 0.12.2
。这是个问题吗?
为了消除几个不相关的弃用警告,我不得不对这些文件进行更改。复制自 git diff
在这里注明,以防万一...
config/environments/production.rb
- config.serve_static_files = false
+ config.public_file_server.enabled = false
config/environments/staging.rb
- config.serve_static_files = false
+ config.public_file_server.enabled = false
config/environments/test.rb
- config.serve_static_files = true
+ config.public_file_server.enabled = true
- config.static_cache_control = "public, max-age=3600"
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
运行 规范测试
jdc44@dev:~/apps/ereqs$ bundle exec rake
...
Coverage report generated for RSpec to /home/STATLER/jdc44/apps/ereqs/coverage. 3 / 892 LOC (0.34%) covered.
SimpleCov failed with exit 1
Traceback (most recent call last):
30: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/exe/rspec:4:in `<main>'
29: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:45:in `invoke'
28: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:71:in `run'
27: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:86:in `run'
26: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/runner.rb:100:in `setup'
25: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
24: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1433:in `each'
23: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
22: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.3/lib/rspec/core/configuration.rb:1435:in `load'
21: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `<top (required)>'
20: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `require'
19: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `<top (required)>'
18: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `require'
17: from /home/STATLER/jdc44/apps/ereqs/config/environment.rb:5:in `<top (required)>'
16: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `method_missing'
15: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/railtie.rb:193:in `public_send'
14: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/application.rb:352:in `initialize!'
13: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:54:in `run_initializers'
12: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
11: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
10: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
9: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `call'
8: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:347:in `each'
7: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
6: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
5: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
4: from /usr/local/rvm/rubies/ruby-2.6.4/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
3: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:55:in `block in run_initializers'
2: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `run'
1: from /home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/railties-5.0.7.2/lib/rails/initializable.rb:30:in `instance_exec'
/home/STATLER/jdc44/apps/ereqs/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:105:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need
to be rendered by your app:
Example:
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
and restart your server
我不认为 manifest.js 输出是相关的,但保留它以防万一它是任何人的线索。
第 18 - 21 行包括我们编写的两个文件(不是由 ruby/rails 创建的)。
21: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `<top (required)>'
20: from /home/STATLER/jdc44/apps/ereqs/spec/controllers/admins/account_codes_controller_spec.rb:1:in `require'
19: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `<top (required)>'
18: from /home/STATLER/jdc44/apps/ereqs/spec/spec_helper.rb:6:in `require'
spec/controllers/admins/account_codes_controller_spec.rb (with line nbr)
1 require 'spec_helper'
spec/spec_helper.rb (with line nbrs)
1 require 'simplecov'
2 SimpleCov.start 'rails'
3
4 # This file is copied to spec/ when you run 'rails generate rspec:install'
5 ENV["RAILS_ENV"] ||= 'test'
6 require File.expand_path("../../config/environment", __FILE__)
7 require 'rspec/rails'
8 require 'capybara/rspec'
9 require 'webmock/rspec'
10 require 'statlerwire/spec_helpers'
我不知道任何可能包含任何线索的日志文件。我通过 Google 阅读了很多主题,但没有找到与我的实际主题相关的主题。
如有任何帮助,我们将不胜感激。
约翰·C
因为 simplecov
仍然出现在您的 Gemfile.lock
文件中,您最好的操作是删除 Gemfile.lock
文件,然后 运行 bundle install
。这将重新创建您的 Gemfile.lock
文件并且 simplecov
应该消失。