2012-06-20 5 views
1

http://ruby.railstutorial.org/chapters/static-pages#code:pages_controller_spec_titleМой тест Rspec отказывается работать

Мой код выглядит следующим образом. При раскомментировании тест не запускается. Ниже приведена комментированная версия кода, которая позволяет инициировать определенный тест. Я не знаю, как отформатировать этот вопрос с помощью цвета синтаксиса ruby. Не кричите на меня.

require 'spec_helper' 

describe "Static Pages" do 
    describe "Home page" do 
    it "should have the h1 'Sample App'" do 
     visit '/static_pages/home' 
     page.should have_selector('h1', :text =>'Sample App') 
    end 
    it "should have the title 'Home'" do 
     visit '/static_pages/home' 
     page.should have_selector('title', 
     :text => "Ruby on Rails Tutorial Sample App | Home") 
    end 
    end 

    describe "Help Page" do 
    it "should have the h1 'Help'" do 
     visit '/static_pages/help' 
     page.should have_selector('h1', :text =>'Help') 
    end 
    it "should have the title 'Help'" do 
     visit '/static_pages/help' 
     page.should have_selector('title', 
     :text => "Ruby on Rails Tutorial Sample App | Help") 
    end 
    end 

    describe "About Page" do 
    it "should have the h1 'About us'" do 
     visit '/static_pages/about' 
     page.should have_selector('h1', :text => 'About us') 
    end 
    it "should have the title 'About us'" do 
     visit '/static_pages/about' 
     page.should have_selector('title', 
     :text => "Ruby on Rails Tutorial Sample App | About us") 
    end 
    end 

    # describe 'Contact' do 
    #  it "Should have the h1 'Contact'" do 
    #  visit "static_pages/contact" 
    #  page.should have_selector('h1', :text => 'Contact') 
    #  end 
    #  it "should have the title 'Contact'" 
    #  visit "static_pages/contact" 
    #  page.should have_selector('title', 
    #  :text => "Ruby on Rails Tutorial Sample App | Contact") 
    #  end 
    # end  
end 

ответ

2

Я предполагаю, что вы забыли do в конце этой линии:

it "should have the title 'Contact'" 
            ^
+0

Человек, усталые глаза. Извлеченный урок, иногда его хорошо спать на нем. Спасибо, что посмотрели. –

Смежные вопросы