【发布时间】:2010-11-06 16:39:00
【问题描述】:
我正在使用 Micheal Hartl 源代码 (railstutorial) 使用 Rspec 测试设计
虽然启用了可确认模块,但我不明白为什么这个测试通过了:
spec/models/user_spec.rb
require 'spec_helper'
describe User do
before(:each) do
@attr = { :username => "ExampleUser",
:email => "user@example.com",
:password => 'test1234',
}
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
end
基本上,我想确定这段代码确实如此,它测试的是用户的创建,而不是这个验证(因为用户尚未确认并且测试返回 true)?是这样吗?
另外,我没有提供密码确认的属性,还是创建了用户!
这是否意味着 :validatable 模块中没有 (?):
validates :password, :confirmation => true
感谢您对此的看法!
【问题讨论】:
标签: ruby-on-rails rspec devise