预期的CSS“标题”与水豚文本(expected css “title” with text in capybara)
我正在使用水豚代替轨道中的网页。 我已经安装了水豚,并在Gemfile中使用gem'水豚'。 当我使用
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 endI am using capybara in place of webrat in rails. I have installed capybara and use gem 'capybara' in Gemfile. when I use
page.should have_selector("title", :text => "anything title")it's give an error
Failure/Error: page.should have_selector("title", :text => "anything title") expected css "title" with text "anything title" to return somethingtest file is as below:
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最满意答案
不知道你使用的是哪个版本的宝石,但我遇到了类似的情况,使用:文本失败,但是当我使用:内容通过测试。 我在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")同
page.should have_selector("title", :content => "anything title")Not sure which version of gems you are using but I ran into a similar instance where using :text failed but when I used :content it passed the test. I'm using rails 3.2.3, rspec-rails 2.9.0, capybara 1.1.2 and therubyracer gems on Ubuntu Lucid Lynx.
Try replacing
page.should have_selector("title", :text => "anything title")with
page.should have_selector("title", :content => "anything title")更多推荐
发布评论