Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to use spring with rspec and guard on a Rails 3.2.16 project.

After installing spring and spring-commands-rspec, I created the binstubs with :

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

Now trying to run spec with spring fails (gems paths and project path subtituted for legibility) :

> 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'

Other try :

> spring rspec

Only displays spring help

Same goes for

> spring rspec spec/

Here is the 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')

Any idea ?

like image 377
demental Avatar asked Jan 20 '14 11:01

demental


3 Answers

I had the same problem. I've solved it by stopping spring and adding to my Gemfile:

gem 'spring-commands-rspec', group: :development, require: false

Spring needs to be restarted in order to use the newly added command.

bin/spring stop
bin/rspec path/to/file.rb
like image 134
pfleidi Avatar answered Oct 18 '22 15:10

pfleidi


ANSWER OUTDATED! Was fixed. See @pfleidi's answer below.

I've solved the problem, even if i dont know why it has solved the problem.

Just remove gem 'spring', group: :development from the Gemfile so that you only have gem 'spring-commands-rspec' left.

Run bundle install and then spring rpsec spec will work! Its sooo fast :)

like image 28
Philip Giuliani Avatar answered Oct 18 '22 14:10

Philip Giuliani


You have to restart the spring. So stop it and then re-run it

spring stop

spring rspec

Then it should works as expected.

like image 10
Scudelletti Avatar answered Oct 18 '22 15:10

Scudelletti