我的Rspec不起作用

时间:2013-07-25 13:27:47

标签: ruby-on-rails rspec railstutorial.org

这是我在尝试执行bundle exec rspec spec / requests / static_pages_spec.rb时遇到的错误:

No DRb server is running. Running in local process instead ...
/Users/hetzerbr/sample_app/spec/requests/static_pages_spec.rb:1:in `require': /Users/hetzerbr/sample_app/spec/spec_helper.rb:29: syntax error, unexpected tASSOC, expecting kEND (SyntaxError)
    config.fixture_path => "#{::Rails.root}/spec/fixtures"
                          ^
    from /Users/hetzerbr/sample_app/spec/requests/static_pages_spec.rb:1
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `run'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `autorun'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/bin/ruby_noexec_wrapper:14

我正在使用Mac Osx10.8与brew安装以及RVM和ruby 1.8.7。我正处于ruby on rails教程的第五章中间 但是,通过以下评论固定,现在我收到了这个错误:

rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:177:in `require': no such file to load -- iconv (LoadError)
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs/external_runtime.rb:177
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs/runtimes.rb:3:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs/runtimes.rb:3
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs.rb:2:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/execjs-1.4.0/lib/execjs.rb:2
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/hetzerbr/sample_app/config/application.rb:13
    from /Users/hetzerbr/sample_app/config/environment.rb:2:in `require'
    from /Users/hetzerbr/sample_app/config/environment.rb:2
    from /Users/hetzerbr/sample_app/spec/spec_helper.rb:10:in `require'
    from /Users/hetzerbr/sample_app/spec/spec_helper.rb:10
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/spork-0.9.0/lib/spork.rb:24:in `prefork'
    from /Users/hetzerbr/sample_app/spec/spec_helper.rb:4
    from /Users/hetzerbr/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
    from /Users/hetzerbr/sample_app/spec/requests/static_pages_spec.rb:1
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `run'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `autorun'
    from /Users/hetzerbr/.rvm/gems/ruby-1.8.7-p374/bin/ruby_noexec_wrapper:14

1 个答案:

答案 0 :(得分:1)

问题是你使用火箭记谱法来赋值,你应该使用=(等于)符号。在您spec/spec_helper.rb中,找到第config.fixture_path行并修改如下:

config.fixture_path = "#{::Rails.root}/spec/fixtures"

再次尝试运行测试。