gpt4 book ai didi

ruby-on-rails - 在 rspec : `formatted_backtrace' : undefined method `backtrace' 中运行所有项目规范时出错

转载 作者:太空宇宙 更新时间:2023-11-03 16:23:15 24 4
gpt4 key购买 nike

每当我在完成所有测试用例后尝试为整个项目(有超过 1000 个测试)运行 rspec 时,我都会收到以下错误:

/home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:183:in `formatted_backtrace': undefined method `backtrace' for nil:NilClass (NoMethodError)
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:191:in `colorized_formatted_backtrace'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:276:in `formatted_message_and_backtrace'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:199:in `fully_formatted'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:122:in `block in fully_formatted_pending_examples'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:121:in `each'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:121:in `each_with_index'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/notifications.rb:121:in `fully_formatted_pending_examples'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/formatters/base_text_formatter.rb:50:in `dump_pending'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/reporter.rb:146:in `block in notify'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/reporter.rb:145:in `each'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/reporter.rb:145:in `notify'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/reporter.rb:123:in `finish'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/reporter.rb:64:in `report'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:108:in `run_specs'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:86:in `run'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:70:in `run'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/lib/rspec/core/runner.rb:38:in `invoke'
from /home/borisano/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.2/exe/rspec:4:in `<top (required)>'
from /home/borisano/.rbenv/versions/2.1.5/bin/rspec:23:in `load'
from /home/borisano/.rbenv/versions/2.1.5/bin/rspec:23:in `<main>'

当我只运行有限数量的测试用例时,比如一个文件或一个文件夹,一切正常。

这是我的.rspec 文件

--color
--require rails_helper

spec_helper.rb

require "rack_session_access/capybara"
RSpec.configure do |config|
end

所以没有什么可疑的,至于我

关于如何解决这个问题有什么想法吗?

最佳答案

将此添加到您的 .rspec 文件中:

--require spec_helper

这保证在每个规范之前都需要您的 spec_helper。

关于ruby-on-rails - 在 rspec : `formatted_backtrace' : undefined method `backtrace' 中运行所有项目规范时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30100628/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com