Shoulda教程之三—测试ActiveRecord模型

ActiveRecord助手方法 Shoulda具有一套ActiveRecord测试宏,这让开发效率大大提高,TDD变得轻而易举。关于这个方面的所有的文档都在Shoulda的Rdoc中。下面就来个小小的例子: class UserTest :dogs  should_belong_to :lover end 上面的代码创建了如下的测试: test: Person should allow phone_number to be set to “(123) 456-7890″. test: Person should belong to lover. test: Person should have many dogs. test: Person should have many messes through dogs. test: Person should have one profile. test: Person should not allow admin to be changed by update. test: Person should not allow phone_number to be set [...]

你可能感兴趣的:(TDD,ActiveRecord)