浏览 440 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-12-27
flash.now在正常情况下当 action结束时会被清理,所以在测试中无法获取它,如何在RSpec中获取flash.now,我们需要通过重写flash来得到,在spec_helper .rb文件中加入一下代码就可以在测试中测试flash.now:
module ActionController
module Flash
class FlashHash
def initialize
@hash = {}
@now_hash = {}
end
def [](key)
@hash[key]
end
def []=(key, obj)
@hash[key] = obj
end
def discard(k = nil)
initialize
end
def now
@now_hash
end
def update(hash)
@hash.update(hash)
end
def sweep
# do nothing
end
end
end
end
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
| 返回顶楼 | |


