gpt4 book ai didi

ruby-on-rails - rspec 和 gem bullet test env 失败

转载 作者:数据小太阳 更新时间:2023-10-29 08:30:43 27 4
gpt4 key购买 nike

我想用 gem bullet 运行 rspec 找出所有弱点。我正在做如下:

gem 文件

group :development, :test do
gem "bullet"
end

配置/环境/test.rb

  config.after_initialize do
Bullet.enable = true
Bullet.rails_logger = true
Bullet.raise = true # raise an error if n+1 query occurs
end

规范/spec_helper.rb

    if Bullet.enable?
config.before(:each) do
Bullet.start_request
end

config.after(:each) do
Bullet.perform_out_of_channel_notifications if Bullet.notification?
Bullet.end_request
end
end

但是当我尝试运行 rspec 时出现错误

% bundle exec rspec
/spec/spec_helper.rb:24:in `block in <top (required)>': uninitialized constant Bullet (NameError)

请帮我解决这个问题

最佳答案

在我这边,我需要补充

require "active_record"
require "bullet"

都在 spec/spec_helper.rbenvironments/test.rb

关于ruby-on-rails - rspec 和 gem bullet test env 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37323610/

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