我使用Ruby on Rails创建了一个小型应用程序,并测试了该应用程序的输出三个错误。但是,这些错误似乎是不规则的。例如,每个错误都要求我在源代码文件行中根本不需要的位置插入一个括号。这是一组错误:
1) Error:
StaticPagesControllerTest#test_should_get_about:
SyntaxError: C:/Sites/sample_app/app/views/static_pages/about.html.erb:1: syntax error, unexpected ',', expecting ')'
...putBuffer.new; provide (:title, "About")
... ^
C:/Sites/sample_app/app/views/static_pages/about.html.erb:1: syntax error, unexpected ')', expecting keyword_end
....new; provide (:title, "About")
... ^
test/controllers/static_pages_controller_test.rb:17:in `block in <class:StaticPagesControllerTest>'
2) Error:
StaticPagesControllerTest#test_should_get_help:
SyntaxError: C:/Sites/sample_app/app/views/static_pages/help.html.erb:1: syntax error, unexpected ',', expecting ')'
...putBuffer.new; provide (:title, "Help")
... ^
C:/Sites/sample_app/app/views/static_pages/help.html.erb:1: syntax error, unexpected ')', expecting keyword_end
...r.new; provide (:title, "Help")
... ^
test/controllers/static_pages_controller_test.rb:11:in `block in <class:StaticPagesControllerTest>'
3) Error:
StaticPagesControllerTest#test_should_get_home:
SyntaxError: C:/Sites/sample_app/app/views/static_pages/home.html.erb:1: syntax error, unexpected ',', expecting ')'
...putBuffer.new; provide (:title, "Home")
... ^
C:/Sites/sample_app/app/views/static_pages/home.html.erb:1: syntax error, unexpected ')', expecting keyword_end
...r.new; provide (:title, "Home")
... ^
test/controllers/static_pages_controller_test.rb:5:in `block in <class:StaticPagesControllerTest>'
如果需要,如何在程序中更正此错误?程序方面是否还支持我?
最佳答案
尝试provide(:title, 'About')
。即,provide
后没有空格