1

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

0 に答える 0