2008-01-28
rspec_matchers真弱
关键字: rspec_matchers
使用Mocha时,发现Model的find方法的返回值变成true了
几经折腾,发现是rspec_matchers这个plugin的一段代码导致的:
find方法被stub为返回true了,靠!
还有一段代码:
很可爱的plugin
几经折腾,发现是rspec_matchers这个plugin的一段代码导致的:
def validate_uniqueness_of(attribute)
return simple_matcher("model to validate the uniqueness of #{attribute}") do |model|
model.class.stub!(:find).and_return(true)
!model.valid? && model.errors.invalid?(attribute)
end
end
find方法被stub为返回true了,靠!
还有一段代码:
def validate_confirmation_of(attribute)
return simple_matcher("model to validate the confirmation of #{attribute}") do |model|
model.send("#{attribute}_confirmation=", 'asdf')
!model.valid? && model.errors.invalid?(attribute)
end
end
很可爱的plugin
发表评论
- 浏览: 723114 次
- 性别:

- 来自: BJ

- 详细资料
搜索本博客
我的相册
screenshot
共 1 张
共 1 张
最近加入圈子
最新评论
-
Why OO sucks
看成去QQ SUCK 了
-- by xhanxhanxhan -
Rails的富文本编辑器插件 ...
有没有那个像textmate那种语法高亮的富文本编辑器?
-- by zllicho -
翻译www.djangobook.com之 ...
weiertzw 写道 1. >>> from django. ...
-- by chenjihua75 -
PHP、CakePHP哪凉快哪呆 ...
这孩子被java毒害太深。。。跳出java,你会发现外面的世界真的很大。
-- by woodless -
学习svn命令
只会用 apt-get 不是好孩子。
-- by smartly






评论排行榜