无法识别set_the_flash` []`方法的测试

时间:2013-06-26 12:54:12

标签: ruby-on-rails ruby-on-rails-3 shoulda

我正在尝试将flash的值调用到控制器中。

def upload
  ...
  flash[:error] = 'error'
  redirect_to :action => 'index'
end

要执行此操作,我将set_the_flashshoulda一起使用,如下所示:

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") }

0 个答案:

没有答案