我正在使用 Rails 3.0.1、RSpec-Rails 2.0.1 和 Webrat 0.7.1。我有以下测试:
describe PagesController do
describe "GET 'main'" do
it "should have the right title" do
get 'main'
response.should have_selector("title", :content => "My title")
end
end
end
pages#main 的 HTML 签出:它包含我的标题。当我运行 rspec 时,它让我在这个测试中失败,并说它希望在以下行中找到标记:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
由于这不是存储在 pages#main 中的文件,因此我认为 rspec 出于某种原因加载了错误的页面。我该如何解决这个问题?或者,如果没有一个通用的解决方案,我怎样才能让 rspec 告诉我它正在尝试加载哪个页面,以便我可以尝试找出它为什么会转到另一个页面?谢谢。