2017-05-23 69 views
1

我是一個試圖學習rails的初學者。當我試圖運行「rails test」命令時,我收到了這條消息。我不明白這是什麼消息是:/終端上的滑軌測試錯誤

rails test 
Running via Spring preloader in process 46753 
/Users/.../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require': /Users/..../test/controllers/static_pages_controller_test.rb:26: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError) 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `block in require' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:258:in `load_dependency' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:14:in `block in require_files' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:13:in `each' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:13:in `require_files' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/minitest_plugin.rb:94:in `plugin_rails_init' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:81:in `block in init_plugins' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:79:in `each' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:79:in `init_plugins' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:130:in `run' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/minitest_plugin.rb:77:in `run' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:63:in `block in autorun' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /Users/..../.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from -e:1:in `<main>' 
+5

它意味着它說'static_pages_controller_test.rb:26:語法錯誤,意外的輸入結束,期待keyword_end(SyntaxError)''。因此,在錯誤消息中指定的文件中可能存在語法錯誤。 –

回答

3

錯誤消息實際上是告訴你確切位置問題。

在您的static_pages_controller_test.rb文件的第26行,您缺少一個end

...static_pages_controller_test.rb:26: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)... 
0

它告訴你,你可能已經從您的static_pages_controller_test.rb文件ommitted的end。或者,您在該文件中還有一個額外的end

如果你看一下錯誤:

..../test/controllers/static_pages_controller_test.rb:26 syntax error, 
    unexpected end-of-input, expecting keyword_end (SyntaxError)` 

它告訴你,什麼是上線26 不對勁然後syntax error,意味着你已經輸入錯誤的東西。 然後它說unexpected end-of-input這意味着解析器不知道在哪裏結束該方法,原因是它是expecting keyword_end,這意味着有一個end關鍵字缺失。