代码之家  ›  专栏  ›  技术社区  ›  Steve Horn

我如何测试这个Sinatra方法?

  •  0
  • Steve Horn  · 技术社区  · 14 年前

    简单的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 方法?嘲笑 不知怎么的?

    1 回复  |  直到 14 年前
        1
  •  -1
  •   Scott Watermasysk    14 年前

    测试呈现的实际标记呢?