2014-01-20 59 views
24

我試圖用rspec和guard在一個Rails 3.2.16項目上使用spring。`春天RSpec`只顯示春天幫助..爲什麼?

安裝春春的命令-rspec的後,我創建了binstubs有:

> bundle exec spring binstub --all 
    * bin/rake: spring inserted 
    * bin/rspec: spring inserted 
    * bin/rails: spring inserted 

現在試圖用簧運行規範失敗(subtituted易於識別的寶石路徑和項目路徑):

> bin/rspec spec/ 
Version: 1.1.0 

Usage: spring COMMAND [ARGS] 

Commands for spring itself: 

binstub   Generate spring based binstubs. Use --all to generate a binstub for all known commands. 
help   Print available commands. 
status   Show current status. 
stop   Stop all spring processes for this project. 

Commands for your application: 

rails   Run a rails command. The following sub commands will use spring: console, runner, generate, destroy. 
rake   Runs the rake command 
rspec   Runs the rspec command 
rspec binstub 
No DRb server is running. Running in local process instead ... 
gemspath/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- [PROJECT_PATH]/rspec (LoadError) 
from gemspath/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/runner.rb:77:in `rescue in run' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/runner.rb:73:in `run' 
from gemspath/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun' 

其他嘗試:

> spring rspec 

僅顯示彈簧幫助

也是一樣

> spring rspec spec/ 

這裏是RSpec的binstub(BIN/rspec的):

#!/usr/bin/env ruby 
begin 
    load File.expand_path("../spring", __FILE__) 
rescue LoadError 
end 
require 'bundler/setup' 
load Gem.bin_path('rspec', 'rspec') 

任何想法?

+0

我有完全相同的問題。我希望有人會回答! –

+5

'bundle exec spring stop'然後'bundle exec spring start'爲我解決了它。 –

+0

@DarshanSawardekar它沒有解決我的問題,'春天開始'不存在。你正在運行哪個rspec版本?我有3.0.0-beta1。可能是因爲這個原因。 –

回答

9

ANSWER OUTDATED!已修復。請參閱下面的@ pfleidi的答案。

我已經解決了這個問題,即使我不知道它爲什麼解決了這個問題。

只需從Gemfile中刪除gem 'spring', group: :development,以便您只剩下gem 'spring-commands-rspec'左側。

運行bundle install然後spring rpsec spec將工作!它sooo快:)

+7

pfleidi的回答是正確的 – keyvan

+0

是的,我似乎在新的spring-commands-rspec版本中修復了這個bug。 –

+0

不,這個解決方案僅僅是運氣。如果你不重新啓動彈簧,這將不起作用。 – mhutter

56

我有同樣的問題。我已經通過在添加spring-commands-rspec後停止彈簧來解決它。它看起來像需要重新啓動才能使用新添加的命令。

bin/spring stop 
bin/rspec path/to/file.rb 
+0

這是爲我修復的問題 – jpcamara

+0

爲我效勞了! – wrzasa

9

您必須重新啓動彈簧。因此,停止它,然後重新運行它

spring stop

spring rspec

那麼就應該按預期工作。

+0

謝謝,這就是我所缺少的。 :) –