我正在使用RSpec + capybara进行测试,但我得到了错误:
Failure/Error: page.should have_selector('title', :text => "YourPos | About")
expected #has_selector?("title", {:text=>"YourPos | About"}) to return true, got false
# ./spec/requests/static_pages_spec.rb:14:in `block (3 levels) in <top (required)>'
我的static_pages_spec.rb
require 'spec_helper'
describe "Static pages" do
describe "About page" do
it "should have the title 'About' " do
visit '/static_pages/about'
page.should have_selector('title', :text => "YourPos | About")
end
end
end
我的app / views / static_pages / about.html.erb
<!DOCTYPE html>
<html>
<head>
<title>YourPos | About</title>
</head>
<body>
<p>Find me in app/views/static_pages/home.html.erb</p>
</body>
</html>
希望有人能帮助我,非常感谢。
答案 0 :(得分:1)
尝试更改
visit 'static_pages/about'
到
visit '/static_pages/about'