Rails RSpec 测试,怎么初始化测试数据库?

hlcfan · June 06, 2012 · Last by hlcfan replied at June 06, 2012 · 4101 hits

我正在尝试写测试,以前没写过。 使用 RSpec Development DB:shurlin Test DB:shurlin_test 怎么初始化 shurlin_test 的数据?

如果是基础数据,seeds.rb 如果是测试用的数据 factorygirl

#1 楼 @ywencn 谢谢,我试试。 你又换头像了。man

$ bundle exec rake -D db:create
rake db:create
    Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config)

#3 楼 @lgn21st 谢谢,这个没问题!我可以通过这个命令创建表,那怎么往表里插入数据呢?

#5 楼 @lgn21st 非常感谢!我在看。

You need to Sign in before reply, if you don't have an account, please Sign up first.