我正在使用 capybara 代替 rails 中的 webrat。我已经安装了 capybara 并在 Gemfile 中使用了 gem 'capybara'。当我使用
page.should have_selector("title", :text => "anything title")
它给出了一个错误
Failure/Error: page.should have_selector("title", :text => "anything title")
expected css "title" with text "anything title" to return something
测试文件如下:
require 'spec_helper'
describe "Test pages" do
describe "Home page" do
it "should have the content 'Demo App'" do
visit '/test_pages/home'
page.should have_selector("title", :text => "anything title")
end
end
end