Ошибки с руководством Rails Майкла Хартла Глава 7 - В частности, ошибки тестирования Rspec - PullRequest
0 голосов
/ 24 октября 2010

До сих пор я не получил никаких ошибок в тестах, но я не могу выяснить эти ошибки.

    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

Ответы [ 2 ]

2 голосов
/ 24 октября 2010
0 голосов
/ 13 июня 2012

Я получаю те же ошибки, так что расстраивает .. Обновленный пакет, перезапустил автотест безрезультатно. Эта ссылка помогла мне, оказывается, синтаксис в файле контроллера (в книге Майкла Хартла) неверен .. Попробуйтеу меня это сработало:

response.should contain("Ruby on Rails Tutorial Sample App | Home")[Found out it was a syntax issus on this site][1]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...