тестирование со спецификациями, капибара из главы 3 railstutorial не работает (есть _селектор ('название', :текст => ' | Дом'))

Я работаю над ruby.railstutorial.org/ruby -над -rails -tutorial -book. Я использую рельсы 3.2.7, spork, rspec, capybara, launchy и некоторые охранники:)

у меня действительно странная проблема в главе 3 с тестированием:

Похоже, тесты не работают с тем, что внутри-Ярлык. Если я поставлю</code>-тег внутри<code><body></code>-тег вместо заголовка -работает нормально. Также это работает, когда я ставлю<code><h1></code>-теги над <code><title></code>внутри<code><head></code>-Теги. Это странно, не так ли?</p><p>Пожалуйста, помогите мне разобраться.</p><p>Пример взят из :ruby.railstutorial.org/chapters/static -pages #code :title _test:</p><pre><code>it "should have the right title" do visit '/static_pages/home' page.should have_selector('title', :text => "Ruby on Rails Tutorial Sample App | Home") end </code></pre><p>Сообщение об ошибке -:</p><blockquote> <p>Failures:</p> <p>1) Static pages Home page should have the title 'Home' Failure/Error: page.should have_selector('title', :text => ' | Home') Capybara::ExpectationNotMet: expected to find css "title" with text " | Home" but there were no matches. Also found "", which matched the selector but not all filters. #./spec/requests/static_pages_spec.rb:15:in `block (3 levels) in '</p> </blockquote><p>Тот работает:</p><pre><code>it "should have the h1 'Sample App'" do visit '/static_pages/home' page.should have_selector('h1', :text => 'Sample App') end </code></pre><p>визуализированный файл HTML -:</p><pre><code><!DOCTYPE html> <html> <head> <title>Ruby on Rails Tutorial Sample App | Home

Sample App

This is the home page for the Ruby on Rails Tutorial sample application

Спасибо

Изменить :вы можете найти файлы, с которыми я работаю, на github: https://github.com/farukg/sample_app/

ссылка на файл спецификации: https://github.com/farukg/sample_app/blob/master/spec/requests/static_pages_spec.rb

Объяснение того, что я сделал :Код главной страницы такой, каким и должен быть. Код страницы about имеет собственный макет с тегом h1 -над тегом title -внутри, чтобы показать, что он работает по какой-то причине. И, наконец, страница справки имеет свой тег заголовка внутри тегов тела, что тоже работает.

Я совсем запутался, почему у меня такое странное поведение?

полный вывод охраны:

> Run all
Bundle already up-to-date
Running all specs
Running tests with args ["--drb", "--colour", "-f", "progress", "-r", "/home/faruk/.rvm/gems/ruby-1.9.3-p125/gems/guard-rspec-1.2.0/lib/guard/rspec/formatters/notification_rspec.rb", "-f", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--failure-exit-code", "2", "spec"]...
..FFF.....Neues Fenster in aktueller Browsersitzung erstellt.
.FF..

Failures:

  1) Static pages Home page having application layout should have_selector head title 'Home'
     Failure/Error: page.should have_selector('head title',
     Capybara::ExpectationNotMet:
       expected to find css "head title" with text "Ruby on Rails Tutorial Sample App | Home" but there were no matches. Also found "", which matched the selector but not all filters.
     #./spec/requests/static_pages_spec.rb:23:in `block (3 levels) in '

  2) Static pages Home page having application layout should have content 'Home'
     Failure/Error: page.should have_content("Ruby on Rails Tutorial Sample App | Home")
       expected there to be text "Ruby on Rails Tutorial Sample App | Home" in "Sample App This is the home page for the Ruby on Rails Tutorial sample application"
     #./spec/requests/static_pages_spec.rb:30:in `block (3 levels) in '

  3) Static pages Home page having application layout should have css title 'Home'
     Failure/Error: page.should have_css("title", :text => "Ruby on Rails Tutorial Sample App | Home")
     Capybara::ExpectationNotMet:
       expected to find css "title" with text "Ruby on Rails Tutorial Sample App | Home" but there were no matches. Also found "", which matched the selector but not all filters.
     #./spec/requests/static_pages_spec.rb:36:in `block (3 levels) in '

  4) Static pages about page with own layout should JUST have_selector head title 
     Failure/Error: page.should have_selector('head title')
     Capybara::ExpectationNotMet:
       expected to find css "head title" but there were no matches
     #./spec/requests/static_pages_spec.rb:86:in `block (3 levels) in '

  5) Static pages about page with own layout should have_selector head title 'About Us'
     Failure/Error: page.should have_selector('head title',
     Capybara::ExpectationNotMet:
       expected to find css "head title" with text "Ruby on Rails Tutorial Sample App | About Us" but there were no matches
     #./spec/requests/static_pages_spec.rb:93:in `block (3 levels) in '

Finished in 0.66215 seconds
15 examples, 5 failures

Failed examples:

rspec./spec/requests/static_pages_spec.rb:20 # Static pages Home page having application layout should have_selector head title 'Home'
rspec./spec/requests/static_pages_spec.rb:27 # Static pages Home page having application layout should have content 'Home'
rspec./spec/requests/static_pages_spec.rb:33 # Static pages Home page having application layout should have css title 'Home'
rspec./spec/requests/static_pages_spec.rb:83 # Static pages about page with own layout should JUST have_selector head title 
rspec./spec/requests/static_pages_spec.rb:90 # Static pages about page with own layout should have_selector head title 'About Us'
Done.

> Neues Fenster in aktueller Browsersitzung erstellt.
Neues Fenster in aktueller Browsersitzung erstellt.

10
задан farukg 31 July 2012 в 02:32
поделиться