我有一个带有一个模型的裸轨 3 应用程序,使用生成rails g model User
.
我添加了一个工厂(使用factory_girl_rails
):
Factory.define :user do |f|
f.email "[email protected] /cdn-cgi/l/email-protection"
f.password "blah"
f.password_confirmation "blah"
f.display_name "neezer"
end
然后我添加了一项测试:
require 'spec_helper'
describe User do
subject { Factory :user }
it "can be created from a factory" do
subject.should_not be_nil
subject.should be_kind_of User
end
end
Then I 迁移我的数据库 using rake db:migrate
.
然后我使用运行测试rspec spec
,并且测试失败并显示以下内容:
Failures:
1) User can be created from a factory
Failure/Error: subject { Factory :user }
ActiveRecord::StatementInvalid:
Could not find table 'users'
# ./spec/models/user_spec.rb:5:in `block (2 levels) in <top (required)>'
# ./spec/models/user_spec.rb:8:in `block (2 levels) in <top (required)>'
我很困惑,因为我刚刚迁移了我的数据库,而我的schema.db
文件反映存在一个用户表,那么给出了什么?
我知道这是一个初学者的问题,但是把我的头撞在墙上是行不通的......
factory_girl (1.3.3)
factory_girl_rails (1.0.1)
rails (3.0.5)
rspec-rails (2.5.0)
sqlite3 (1.3.3)