关于ruby on rails:`spring rspec`只显示spring帮助。为什么?

`spring rspec` just displays spring help.. why?

我想在Rails 3.2.16项目上使用带有rspec的spring和guard。

安装spring和spring-commands-rspec之后,我使用以下命令创建了binstub:

1
2
3
4
> bundle exec spring binstub --all
  * bin/rake: spring inserted
  * bin/rspec: spring inserted
  * bin/rails: spring inserted

现在尝试使用spring运行spec失败(宝石路径和项目路径被替换为易读性):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
> 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'

其他尝试:

1
> spring rspec

仅显示Spring帮助

一样

1
> spring rspec spec/

这是rspec binstub(bin / rspec):

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

任何的想法 ?


我有同样的问题。 我通过添加spring-commands-rspec后停止spring解决了它。 似乎需要重新启动才能使用新添加的命令。

1
2
bin/spring stop
bin/rspec path/to/file.rb


答案已过时! 是固定的。 请参阅下面的@pfleidi答案。

我已经解决了问题,即使我不知道为什么它也解决了问题。

只需从Gemfile中删除gem 'spring', group: :development,以便只剩下gem 'spring-commands-rspec'

运行bundle install,然后spring rpsec spec将起作用! 太快了:)


您必须重新启动弹簧。 所以停止它,然后重新运行它

spring stop

spring rspec

然后它应该按预期工作。