2010-11-11 85 views
2

我是新来的铁轨,这阻止了我。 我想运行rspec spec /和我得到错误。谁能帮我?

这是我得到的代码:

/Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional_database_support.rb:33: uninitialized constant Rspec::Core (NameError)
from /Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails.rb:1
from /Users/Kendall/Sites/sample_app/spec/spec_helper.rb:4
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Users/Kendall/Sites/sample_app/spec/controllers/pages_controller_spec.rb:1
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `map'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in `load_spec_files'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:18:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:55:in `run_in_process'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:46:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10:in `autorun'
from /usr/bin/rspec:19

回答

2

使用

sudo gem update rspec-rails

+0

这工作谢谢你。 – 2010-12-27 03:32:18

2

看起来你已经安装了RSpec的护栏宝石的旧版本。尝试更新它(2.1.0在写作时的最新版本):

gem update rspec-rails 

更新如下意见

你需要指定一个或多个规格文件或名称包含您的spec文件的目录。使用捆扎机

rspec spec 

在Rails项目:例如,如果你的规范文件是在一个文件夹,名为规范,那么这将运行所有这些

bundle exec rspec spec 

有关RSpec的命令的详细信息:

rspec -h 
+0

做到了,仍然得到了 – 2010-11-11 20:40:44

+0

得到了相同的错误 – 2010-11-11 20:42:04

+0

如果我运行$ rspec – 2010-11-11 20:46:26

0

也许已经晚了,但对于错误:

No examples were matched. Perhaps {:unless=>#<Proc:[email protected]/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:53>, :if=>#<Proc:[email protected]/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:52>} is excluding everything? Finished in 0.00003 seconds 0 examples, 0 failures 

像它说,测试是不是在你的test_spec文件中找到。您应该在测试用例中添加一个“it”表达式。