2012-06-20 52 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

人,疲惫的眼睛。获得的教训,有时它很好睡觉。谢谢参观。 –