我正在尝试将flash
的值调用到控制器中。
def upload
...
flash[:error] = 'error'
redirect_to :action => 'index'
end
要执行此操作,我将set_the_flash
与shoulda
一起使用,如下所示:
should 'be able to upload a file' do
...
set_the_flash[:error].to('error')
end
但是当我运行此测试时,我有这个错误:
NoMethodError:#Shoulda :: ActionController :: Matchers :: SetTheFlashMatcher
的未定义方法`[]'
如果我查看文档,该方法就会出现,它显示的示例与我的完全相同:
# it { should set_the_flash[:alert].to("Password doesn't match") }