gpt4 book ai didi

ruby-on-rails - 针对 seeds.rb 运行 Rails 测试?

转载 作者:行者123 更新时间:2023-11-28 21:03:14 24 4
gpt4 key购买 nike

我想针对当前数据库而不是 fixtures/中的任何内容运行测试。查看我的 SQL 数据库,我有一个 ID 为 1 的视频(模型)。但是,正在运行

ruby functional\videos_controller_test.rb

给我错误:

test_check_video_offsets(VideosControllerTest):
ActiveRecord::RecordNotFound: Couldn't find Video with ID=1
app/controllers/videos_controller.rb:16:in `show'

这就是现在测试中的所有内容:

test "check video offsets" do
get :show, :id => "1"
Rails::logger.debug @video
end

最佳答案

明白了:

rake db:seed RAILS_ENV=test

关于ruby-on-rails - 针对 seeds.rb 运行 Rails 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5284781/

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