免责声明:我刚刚开始使用。
我使用没有选项的rvm安装了Ruby 1.9.3。
我正在关注rails第4版的敏捷开发教程。 当我运行rails rake test:units时出现这个错误:
Ascended:store Ascended$ rake test:units --trace** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute test:prepare
** Execute test:units
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require': /Users/Ascended/Ruby/store/test/unit/product_test.rb:7: syntax error, unexpected tFID, expecting keyword_end (SyntaxError)
/Users/Ascended/Ruby/store/test/unit/product_test.rb:8: syntax error, unexpected '['
assert product.[:price].any?
^
/Users/Ascended/Ruby/store/test/unit/product_test.rb:9: syntax error, unexpected '['
asssert product.[:image_url].any?
^
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
from /Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [/Users/Ascended/.rvm/rubies/ruby-1.9.3-p12...]
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:82:in `ruby'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/testtask.rb:99:in `block (2 levels) in define'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:60:in `verbose'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/testtask.rb:98:in `block in define'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/Ascended/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/Users/Ascended/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'
我不相信它与rails app本身有什么关系,可能是关于环境以及如何安装rake和ruby,可能是rvm如何安装并加载ruby?
我在没有--ggc-clang的情况下安装了xcode和Ruby(读取1.9.3不再需要该选项)
我有点迷失 - 任何帮助都会非常感激。
答案 0 :(得分:0)
正如Ruby告诉你的那样,我认为你有语法错误:
assert product.[:price].any?
应该是:
assert product[:price].any?