Ruby on rails 3 $rspec spec/不为我工作。请帮忙

Ruby on rails 3 $rspec spec/不为我工作。请帮忙,ruby-on-rails-3,rspec2,Ruby On Rails 3,Rspec2,我是rails新手,这让我停滞不前。 我正在尝试运行rspec spec/但出现错误。有人能帮我吗 这是我得到的代码: /Library/Ruby/Gems/1.8/Gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional\u database\u support.rb:33:未初始化常量rspec::Core(namererror) from/Library/Ruby/Gems/1.8/Gems/rspec-rails-2.0.0.a6/l

我是rails新手,这让我停滞不前。 我正在尝试运行rspec spec/但出现错误。有人能帮我吗

这是我得到的代码:

/Library/Ruby/Gems/1.8/Gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional\u database\u support.rb:33:未初始化常量rspec::Core(namererror)
from/Library/Ruby/Gems/1.8/Gems/rspec-rails-2.0.0.a6/lib/rspec/rails.rb:1
来自/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'
来自/Users/Kendall/Sites/sample\u app/spec/controllers/pages\u controller\u 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:在“加载规范文件”中
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:在“加载规范文件”中
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


看起来您已经安装了旧版本的rspec-rails-gem。尝试更新它(2.1.0是撰写本文时的当前版本):

更新了以下评论

您需要指定一个或多个等级库文件的名称或包含等级库文件的目录。例如,如果等级库文件位于名为“等级库”的文件夹中,则这将运行所有等级库文件:

rspec spec
在使用Bundler的Rails项目中:

bundle exec rspec spec
有关rspec命令的更多信息:

rspec -h
使用

sudogem更新rspec-rails


可能是迟到了,但由于错误:

No examples were matched. Perhaps {:unless=>#<Proc:0x00000001005b7790@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:53>, :if=>#<Proc:0x00000001005b7970@/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
没有匹配的示例。也许{:除非=>#,:如果=>#}排除了一切?在0.00003秒内完成0个示例,0个失败

正如上面所说,在测试规范文件中没有找到测试。您应该在测试用例中添加一个“it”表达式。

我发现没有匹配的示例。也许{:除非=>#,:如果=>#}排除了一切?在0.00003秒内完成0个示例,0个失败。您已通过原始错误,现在“没有匹配的示例”?这表明rspec正在工作,但找不到您的测试。非常感谢您的帮助。你对我该做什么有什么想法吗?
No examples were matched. Perhaps {:unless=>#<Proc:0x00000001005b7790@/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:53>, :if=>#<Proc:0x00000001005b7970@/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