我是铁杆新手,这阻止了我。 我试图运行rspec规范/我得到错误。谁能帮我?
这是我得到的代码:
/Library/Ruby/Gems/1.8/gems/rspec-rails-2.0.0.a6/lib/rspec/rails/transactional_database_support.rb:33:未初始化的常量Rspec :: Core(NameError)
来自/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
来自/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in`gem_original_require'
来自/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in`requirent'
来自/Users/Kendall/Sites/sample_app/spec/controllers/pages_controller_spec.rb:1
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in"load'
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in`load_spec_files'
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in`map'
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/configuration.rb:334:in`load_spec_files'
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:18:in“run”
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:55:in“run_in_process”
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:46:in“run”
来自/Library/Ruby/Gems/1.8/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10:in`autorun'
来自/ usr / bin / rspec:19
答案 0 :(得分:2)
看起来您安装了旧版本的rspec-rails gem。尝试更新它(2.1.0是撰写本文时的当前版本):
gem update rspec-rails
更新了以下评论:
您需要指定一个或多个spec文件的名称或包含spec文件的目录。例如,如果您的spec文件位于名为spec的文件夹中,那么这将全部运行它们:
rspec spec
在使用Bundler的Rails项目中:
bundle exec rspec spec
有关rspec命令的更多信息:
rspec -h
答案 1 :(得分:2)
使用
sudo gem update rspec-rails
答案 2 :(得分:0)
也许是迟到了,但是因为错误:
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
就像它说的那样,在test_spec文件中找不到测试。您应该在测试用例中添加“it”表达式。