This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RecordNotFoundMacros | |
def should_raise_record_not_found(&block) | |
should "raise 'Record not Found'" do | |
assert_raise(ActiveRecord::RecordNotFound) {block.bind(self).call} | |
end | |
end | |
end |
こう、呼んであげればと…。
should_raise_record_not_found {get :edit, :id => @なんか.id}
block.bind(self).callで悩んだ。
shouldメソッドに渡すブロックには違うbindingが与えられるので、わざわざselfのを渡しなおしてあげないといけないってことのようでした(たぶん)。
ちょっとしたブロックつきのマクロをたくさん作れるのは便利なんですが、このあたりがちょっと面倒ですね…。
No comments:
Post a Comment