0
平凡西納特拉應用:如何測試Sinatra方法?
require 'rubygems'
require 'sinatra/base'
require 'haml'
class InfoController < Sinatra::Base
get "/" do
haml :index
end
end
而且我的測試:
describe InfoController do
include Rack::Test::Methods
def app
InfoController
end
it "should return the index page when visiting the root of the site" do
get '/'
last_response.should be_ok
end
end
但我不想要測試是否方法工作的HAML,我只是想測試索引視圖被渲染。
你會如何測試?重新定義haml
方法?以某種方式嘲笑haml
方法?
你說,你不想來測試HAML方法是否不工作,但想測試索引視圖被渲染 - 這是同樣的事情,如果haml方法失敗索引視圖渲染也會失敗,也可以嗎?方法僅測試200個狀態碼 – Shtirlic 2010-10-06 11:51:52