`
chenk85
  • 浏览: 42537 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
最近访客 更多访客>>
社区版块
存档分类
最新评论

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 [...]
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics