1

我正在使用 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>

希望有人能帮助我,非常感谢。

4

1 回答 1

1

尝试改变

visit 'static_pages/about'

visit '/static_pages/about'
于 2013-04-01T13:41:16.440 回答