我想用 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.rb
和 environments/test.rb
中
关于ruby-on-rails - rspec 和 gem bullet test env 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37323610/