メモ Railsのコンソールからコントローラのアクションを呼び出せるとちょっとしたテストに便利そうだなと思っていたらやっぱりできるようだ。 ruby script/console # ①URIとメソッドを指定する。 ENV['REQUEST_URI'] = "/example/index/" ENV['REQUEST_METHOD'] = "get" # ②ディスパッチする。 Dispatcher.dispatch ディスパッチすると以下のようにレスポンスがコンソールに出力される。 Content-Type: text/html; charset=utf-8 Set-Cookie: _session=BAh7BiIKZmxhc24501464578d2f; path=/ Status: 200 OK X-Runtime: 3.65600 ETag: "005422c12879c39354f