我有以下规格:
context "no firstname present" do
let(:contact) { build :contact, firstname: 'Mickey', lastname: '', companyname: '' }
it "should be valid" do
should be_valid # Does not work
contact.should be_valid # Works
end
end
为什么should be_valid
失败了,但contact.should be_valid
通过了?在it
块内,无论如何should be_valid
都应该访问contact
?!感谢您的澄清。