我有一个测试用例:
describe User do
let(:user) { create(:user) } # FactoryGirl
it { User.count == 1 }
end
并设置:
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.before(:suite) { DatabaseCleaner.strategy = :truncation }
config.before(:each) { DatabaseCleaner.start }
config.after(:each) { DatabaseCleaner.clean }
config.use_transactional_fixtures = false
end
为什么它不工作?如何使用 let 并得到一个真正持久的记录?