我是初学者,正在尝试学习铁轨。当我试图运行“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>'
答案 0 :(得分:3)
错误消息实际上是告诉您问题的确切位置。
在end
文件的第26行,您错过了...static_pages_controller_test.rb:26: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)...
。
<span class="u2">
Registered<sup>®</sup>
</span>
答案 1 :(得分:0)
它告诉您,您可能已从end
文件中省略了static_pages_controller_test.rb
。或者,您在该文件中有一个额外的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
个关键字丢失。