Trivial Sinatra application:
require 'rubygems'
require 'sinatra/base'
require 'haml'
class InfoController < Sinatra::Base
get "/" do
haml :index
end
end
And my test:
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
But I do not want to test whether or not the haml method worked, I just want to test that the index view was rendered.
How would you test that? Redefine the haml
method? Mock the haml
method somehow?
What about testing the actual markup that was rendered?
last_response.body.should match(/your text/)
精彩评论