0

我安装了 rspec 没有任何问题。但是,当我运行命令时rspec,出现以下错误。任何人都可以帮忙吗?

C:\>ruby -v
ruby 1.9.3p327 (2012-11-10) [i386-mingw32]

C:\>rspec
C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load': cannot load such file -- C:/spec (LoadError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `block in load_spec_files'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/configuration.rb:789:in `load_spec_files'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/command_line.rb:22:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:80:in `run'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.1/lib/rspec/core/runner.rb:17:in `block in autorun'

C:\>gem list --local

*** LOCAL GEMS ***

actionmailer (3.2.9)
actionpack (3.2.9)
activemodel (3.2.9)
activerecord (3.2.9)
activeresource (3.2.9)
activesupport (3.2.9)
archive-tar-minitar (0.5.2)
arel (3.0.2)
awesome_print (1.1.0)
bigdecimal (1.1.0)
builder (3.0.4)
bundler (1.2.2)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.4.0)
columnize (0.3.6)
diff-lcs (1.1.3)
domain_name (0.5.4)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.1)
io-console (0.3)
journey (1.0.4)
jquery-rails (2.1.3)
json (1.7.5, 1.5.4)
linecache19 (0.5.12)
mail (2.4.4)
mechanize (2.5.1)
mechanize-progressbar (0.2.0)
mime-types (1.19)
minitest (2.5.1)
multi_json (1.3.7)
net-http-digest_auth (1.2.1)
net-http-persistent (2.8)
nokogiri (1.5.5 x86-mingw32)
ntlm-http (0.1.1)
ocra (1.3.0)
pik (0.2.8)
polyglot (0.3.3)
progressbar (0.12.0)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.2)
rails (3.2.9)
railties (3.2.9)
rake (10.0.2, 0.9.2.2)
rdiscount (1.6.8)
rdoc (3.12, 3.9.4)
rspec (2.12.0)
rspec-core (2.12.1)
rspec-expectations (2.12.0)
rspec-mocks (2.12.0)
ruby-debug-base19x (0.11.30.pre10, 0.11.30.pre3)
ruby-debug-ide (0.4.17.beta14)
ruby_core_source (0.1.5)
sass (3.2.3)
sass-rails (3.2.5)
shoes (3.0.1)
sprockets (2.2.1)
sqlite3 (1.3.6 x86-mingw32)
thor (0.16.0)
tilt (1.3.3)
tiny_tds (0.5.1 x86-mingw32)
treetop (1.4.12)
tzinfo (0.3.35)
uglifier (1.3.0)
unf (0.0.5)
unf_ext (0.0.5 x86-mingw32)
webrobots (0.0.13)
wxruby-ruby19 (2.0.1 x86-mingw32)

C:\>

编辑:

spec正如大卫指出的那样,我在 c:\ 下没有文件夹。创建该文件夹后,一切似乎都很好。我很抱歉这个愚蠢的问题。我对 rspec 完全陌生。谢谢你们!

C:\>mkdir spec

C:\>rspec
No examples found.


Finished in 0 seconds
0 examples, 0 failures

C:\>
4

1 回答 1

2

rspec命令应该在项目的目录上下文中运行,而不是任意在驱动器的根目录中运行。它在抱怨,因为它找不到spec要执行的特定文件夹。在根部创建一个似乎有点奇怪。

每个项目都应该有自己的spec目录,并且rspec应该从该目录的父级执行命令。

于 2012-12-12T05:03:08.907 回答