Rspec无效选项-f OptionParser

时间:2013-06-07 00:35:59

标签: ruby-on-rails ruby parsing rspec rvm

我最近在nettuts上开始了“Intro to Rails”截屏视频。所以我显然不熟悉Rails,只对Ruby有所了解。代码中的其他所有内容都将正确运行,但是当我运行guard-rspec时,它会显示:

/Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1013:in `block in process_args': invalid option: -f (OptionParser::InvalidOption)
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:992:in `new'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:992:in `process_args'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1042:in `_run'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/minitest/unit.rb:1035:in `run'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:21:in `run'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:774:in `run'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:366:in `block (2 levels) in autorun'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:27:in `run_once'
    from /Users/hanssingh/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/test/unit.rb:365:in `block in autorun'

我不太清楚这个错误意味着什么,我该如何摆脱它?

2 个答案:

答案 0 :(得分:1)

似乎是由转动宝石引起的(我怀疑你有它)。将其从Gemfile中删除,再次运行bundle,然后再次使用guard进行测试。这对我有用。

答案 1 :(得分:0)

在运行Guard时遇到类似问题导致Test :: Unit错误:

/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid option: -f (OptionParser::InvalidOption)

根据https://github.com/guard/guard/issues/170,这是因为我的Gemfile中包含了shoulda gem。将此更改为应该匹配的问题为我解决了问题,而不必失去了应该的可爱。

研究Nettuts的Rails Gemfile简介它似乎包含了基于minitest的'turn'宝石。因此,正如@kladd建议的那样,从Gemfile中删除它应该会有所帮助。