我正在尝试使用带有rspec的spring和在Rails 3.2.16项目中保护。
安装spring和spring-commands-rspec后,我创建了binstubs:
> bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rspec: spring inserted
* bin/rails: spring inserted
现在尝试使用spring运行规范失败(为了易读性而设置了gems路径和项目路径):
> 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 :(得分:57)
我遇到了同样的问题。我在添加spring-commands-rspec
后停止弹簧解决了这个问题。看起来需要重新启动才能使用新添加的命令。
bin/spring stop
bin/rspec path/to/file.rb
答案 1 :(得分:9)
我已经解决了这个问题,即使我不知道它为什么解决了这个问题。
只需从Gemfile中删除gem 'spring', group: :development
,这样您就只剩下gem 'spring-commands-rspec'
。
运行bundle install
,然后spring rpsec spec
就可以了!它太快了:))
答案 2 :(得分:9)
你必须重新启动弹簧。所以停下来然后重新运行它
spring stop
spring rspec
然后它应该按预期工作。