我正在尝试在我的sinatra应用程序的主页(更具体地说,一个padrino应用程序),在rspec中测试重定向.我发现redirect_to,但它似乎只在rspec-rails.你如何在sinatra中测试它?
所以基本上,我会喜欢这样的:
it "Homepage should redirect to locations#index" do get "/" last_response.should be_redirect # This works,but I want it to be more specific # last_response.should redirect_to('/locations') # Only works for rspec-rails end
解决方法
尝试这个(未测试):
it "Homepage should redirect to locations#index" do get "/" last_response.should be_redirect # This works,but I want it to be more specific follow_redirect! last_request.url.should == 'http://example.org/locations' end