2010-11-17 110 views
0

我在運行rspec規範時收到錯誤消息。當我讀取終端輸出時,看起來RVM可能會出現問題。一切都是最新的。如果任何人都可以提供有關這些錯誤的指導,我會很感激。我也包括我建立的頁面控制器,但我正在學習一個教程,所以它基本上只是一個重新打版的副本。爲什麼Rspec與RVM衝突?

Z-Kidds-MacBook-Air:sample_app zkidd$ rspec spec 
/Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load': /Users/zkidd/Sites/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:87: syntax error, unexpected tIDENTIFIER, expecting tCONSTANT (SyntaxError) 
...      ::content => "#{@base_title} + | Cont... 
...        ^
/Users/zkidd/Sites/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:87: syntax error, unexpected ')', expecting keyword_end 
/Users/zkidd/Sites/rails_projects/sample_app/spec/controllers/pages_controller_spec.rb:103: syntax error, unexpected $end, expecting keyword_end 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `block in load_spec_files' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `map' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/configuration.rb:306:in `load_spec_files' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/command_line.rb:18:in `run' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:55:in `run_in_process' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:46:in `run' 
    from /Users/zkidd/.rvm/gems/[email protected]/gems/rspec-core-2.0.1/lib/rspec/core/runner.rb:10:in `block in autorun' 
Z-Kidds-MacBook-Air:sample_app zkidd$ 

這裏是pages_controller_spec.rb

require 'spec_helper' 

describe PagesController do 
    render_views 

    before(:each) do 
    # 
    # Define @base_title here. 
    # 
    end 

    describe "GET 'home'" do 
    it "should be successful" do 
     get 'home' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'home' 
     response.should have_selector("title", 
            :content => "#{@base_title} + | Home") 
    end 
    end 

    describe "GET 'contact'" do 
    it "should be successful" do 
     get 'contact' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'contact' 
     response.should have_selector("title", 
            ::content => "#{@base_title} + | Contact") 
    end 
    end 

    describe "GET 'about'" do 
    it "should be successful" do 
     get 'about' 
     response.should be_success 
    end 

    it "should have the right title" do 
     get 'about' 
     response.should have_selector("title", 
            :content => "#{@base_title} + | About") 
    end 
    end 
end 

回答

3

::content =>應該:content =>

+1

謝謝jdl。 。 。我應該抓住那個。 – zkidd 2010-11-17 03:42:22

+1

一定要記住這種情況,如果你在你的回溯中看到語法錯誤,你可以肯定你已經搞砸了你的代碼中的東西,文件名也被添加,所以你應該知道在哪裏看:-) – Bitterzoet 2010-11-17 10:07:59

1

如果您使用TextMate的工作,你或許應該嘗試使用DR-網卡Ruby和Rails束。他們有一個內置的語法檢查器!

https://github.com/drnic/