2012-10-16 24 views
1

我有一箇舊的rails應用程序,這是在rails 2.3中,我想升級到rails 3.但是在我這樣做之前,我想添加一些rspec測試。由於它是rails 2.3,我相信我必須使用rspec 1.3,這是我遇到的麻煩。如何在rspec 1.3.2中控制器規格

我有一個簡單的控制器:

class MySimpleController < ApplicationController 
    def index 
     ... 
    end 
end 

而且我想寫下的投機/控制器/ my_simple_controller_spec.rb成功規格:

require 'spec_helper' 
describe MySimpleController do 
    controller_name 'my_simple' #do i need this? 
    it "should get index" do 
     get "index" 
     response.should be_sucess 
    end 
end 

我得到的錯誤

ActionController::RoutingError in 'MySimpleController should get index' 
Need controller and action! 

我以爲我在做描述相同的類名稱的事實將工作。

任何幫助表示讚賞

回答

0

我想你可以試試這個,

describe "GET 'index'" do 
    it "returns http success" do 
     get :index 
     response.should be_success 
    end 
    end 

也沒有必要寫控制器的名稱和作用。

+0

不是同一個問題 – Yule

相關問題