2010-10-24 86 views
0

到目前为止,我还没有得到任何错误的测试,但我无法弄清楚这些错误。迈克尔哈特的Rails教程错误教程第7章 - 具体Rspec测试错误

Failures: 
    1) PagesController GET 'home' should have the right title 
    Failure/Error: response.should have_selector("title", 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000100ee9ed0> 
    # ./spec/controllers/pages_controller_spec.rb:18:in `block (3 levels) in <top (required)>' 

    2) PagesController GET 'contact' should have the right title 
    Failure/Error: response.should have_selector("title", 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000100b51f98> 
    # ./spec/controllers/pages_controller_spec.rb:31:in `block (3 levels) in <top (required)>' 

    3) PagesController GET 'about' should have the right title 
    Failure/Error: response.should have_selector("title", 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000103296978> 
    # ./spec/controllers/pages_controller_spec.rb:44:in `block (3 levels) in <top (required)>' 

    4) PagesController GET 'help' should have the right title 
    Failure/Error: response.should have_selector("title", 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000101ddc280> 
    # ./spec/controllers/pages_controller_spec.rb:57:in `block (3 levels) in <top (required)>' 

    5) UsersController GET 'show' should have the right title 
    Failure/Error: response.should have_selector("title", :content => @user.name) 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000101e53f88> 
    # ./spec/controllers/users_controller_spec.rb:24:in `block (3 levels) in <top (required)>' 

    6) UsersController GET 'show' should include the user's name 
    Failure/Error: response.should have_selector("h1", :content => @user.name) 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000101e01620> 
    # ./spec/controllers/users_controller_spec.rb:29:in `block (3 levels) in <top (required)>' 

    7) UsersController GET 'show' should have a profile image 
    Failure/Error: response.should have_selector("h1>img", :class => "gravatar") 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000101d6e938> 
    # ./spec/controllers/users_controller_spec.rb:34:in `block (3 levels) in <top (required)>' 

    8) UsersController GET 'new' should have the right title 
    Failure/Error: response.should have_selector("title", :content => "Sign up") 
    undefined method `has_selector?' for #<ActionController::TestResponse:0x00000100fabe18> 
    # ./spec/controllers/users_controller_spec.rb:47:in `block (3 levels) in <top (required)>' 

    9) LayoutLinks should have a Home page at '/' 
    Failure/Error: response.should have_selector('title', :content => "Home") 
    undefined method `has_selector?' for #<ActionDispatch::TestResponse:0x00000101e6f030> 
    # ./spec/requests/layout_links_spec.rb:6:in `block (2 levels) in <top (required)>' 

    10) LayoutLinks should have a Contact page at '/contact' 
    Failure/Error: response.should have_selector('title', :content => "Contact") 
    undefined method `has_selector?' for #<ActionDispatch::TestResponse:0x00000101e2b678> 
    # ./spec/requests/layout_links_spec.rb:11:in `block (2 levels) in <top (required)>' 

    11) LayoutLinks should have an About page at '/about' 
    Failure/Error: response.should have_selector('title', :content => "About") 
    undefined method `has_selector?' for #<ActionDispatch::TestResponse:0x00000101de9a20> 
    # ./spec/requests/layout_links_spec.rb:16:in `block (2 levels) in <top (required)>' 

    12) LayoutLinks should have a Help page at 'help' 
    Failure/Error: response.should have_selector('title', :content => "Help") 
    undefined method `has_selector?' for #<ActionDispatch::TestResponse:0x00000101cfbbe0> 
    # ./spec/requests/layout_links_spec.rb:21:in `block (2 levels) in <top (required)>' 

    13) LayoutLinks should have a signup page at '/signup' 
    Failure/Error: response.should have_selector('title', :content => "Sign up") 
    undefined method `has_selector?' for #<ActionDispatch::TestResponse:0x000001019f1b20> 
    # ./spec/requests/layout_links_spec.rb:26:in `block (2 levels) in <top (required)>' 

    14) LayoutLinks should have the right links on the layout 
    Failure/Error: visit root_path 
    undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_4:0x00000101ed9d40> 
    # ./spec/requests/layout_links_spec.rb:30:in `block (2 levels) in <top (required)>' 

Finished in 0.76618 seconds 
40 examples, 14 failures 

回答

0

我得到了同样的错误,所以frustrating..Updated捆绑,重新运行自动测试没有avail..This链接帮助我,原来在控制器文件中的语法(在迈克尔哈特尔的书)是不正确的。试试这个,而不是它为我工作:

response.should contain("Ruby on Rails Tutorial Sample App | Home")[Found out it was a syntax issus on this site][1]