我在铁轨中使用水豚代替webrat.我已经安装了水豚并在Gemfile中使用了宝石'capybara'.我用的时候
page.should have_selector("title", :text => "anything title")
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误
Failure/Error: page.should have_selector("title", :text => "anything title")
expected css "title" with text "anything title" to return something
Run Code Online (Sandbox Code Playgroud)
测试文件如下:
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
Run Code Online (Sandbox Code Playgroud)
小智 12
不确定你使用的是哪个版本的宝石,但我遇到了一个使用类似的实例:文本失败但是当我使用时:内容它通过了测试.我在Ubuntu Lucid Lynx上使用rails 3.2.3,rspec-rails 2.9.0,capybara 1.1.2和therubyracer gems.
尝试更换
page.should have_selector("title", :text => "anything title")
Run Code Online (Sandbox Code Playgroud)
同
page.should have_selector("title", :content => "anything title")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7587 次 |
| 最近记录: |