0
我正試圖在模塊化控制器中測試一個簡單的控制器操作。但是,我的get :index
請求返回404而不是200響應。有沒有辦法跟蹤這個get
請求的路由?跟蹤Rspec的控制器操作規範中的獲取請求路由
require "spec_helper"
describe Admin::WidgetsController do
describe "GET index" do
it "has a 200 status code" do
get :index
response.code.should eq("200")
end
end
end
控制器看起來像你所期望的:
class Admin::WidgetsController < Admin::ApplicationController
respond_to :html, :xml, :json
def index
respond_with(@content = "content")
end
end
對不起,你實際上沒有重定向。相反,嘗試像這樣:'params_from(:get,「/ hello/world").should == {:controller =>」hello「,:action =>」world「}' – 2012-03-28 22:01:02
上面設置了對路線的期望失敗應該會給你更多的信息。 – 2012-03-28 22:01:52