我已经安装了database_cleaner
并且对我的所有测试都有效,除非它遇到这个......
scenario "is coach, signs up, email not in const, requests admin status" do
user_sign_in(user1)
visit my_profile_users_path
click_button "Request Admin Status"
expect(ActionMailer::Base.deliveries.count).to eq(1)
end
Rails返回 失败/错误:期望(ActionMailer :: Base.deliveries.count).to eq(1) 预期:1 得到:137 (使用==进行比较)
不确定为什么数据库清理程序在这个实例上失败或如何修复它。任何帮助,将不胜感激。
group :test do
gem 'coveralls', require: false
gem 'database_cleaner'
gem 'launchy', require: false
end
# frozen_string_literal: true
RSpec.configure do |config|
config.before(:each) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) do
DatabaseCleaner.start
end
config.after(:each) do
DatabaseCleaner.clean
end
config.after(:each) do
end
end
require 'spec_helper'
require 'rspec/rails'
require_relative "../spec/support/database_cleaner"
require 'database_cleaner'
答案 0 :(得分:0)
我相信我通过改变测试来解决这个问题。
scenario "is coach, signs up, email not in const, requests admin status" do
user_sign_in(user1)
visit my_profile_users_path
click_button "Request Admin Status"
expect(ActionMailer::Base.deliveries.last.subject).to have_content("#{user1.username} requested admin")
end