来自http://github.com/diaspora/diaspora/blob/master/spec/models/profile_spec.rb
describe Profile do
before do
@person = Factory.build(:person)
end
describe 'requirements' do
it "should include a first name" do
@person.profile = Factory.build(:profile,:first_name => nil)
@person.profile.valid?.should be false
@person.profile.first_name = "Bob"
@person.profile.valid?.should be true
end
end
end
但是在http://github.com/diaspora/diaspora/blob/master/app/models/profile.rb中验证了两者的存在,名字和姓氏像这样validates_presence_of :first_name, :last_name
为什么即使没有指定姓氏,上述测试也会通过?