`spring rspec` just displays spring help.. why?
Asked Answered
B

3

27

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 ?

Blent answered 20/1, 2014 at 11:19 Comment(4)
I have the exactly same problem. I hope somebody will answer!Silberman
bundle exec spring stop and then bundle exec spring start solved it for me.Rectify
@DarshanSawardekar it has not solved the problem for me and spring start is not existing. Which rspec Version have you running? i have 3.0.0-beta1. Probably its because of that.Silberman
Yeah, I'm on 2.14.7. Thanks for posting your answer, will come in handy when I get around to upgrading to 3.0.Rectify
S
13

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 :)

Silberman answered 21/1, 2014 at 14:5 Comment(3)
yes, the bug i had seems to be fixed in the new spring-commands-rspec version.Silberman
No, this solution is mere luck. This won't work if you don't restart spring.Pauiie
At the time of the question, just stopping spring was not working. I tried that 20 times until i found this solution.Silberman
T
59

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
Tigress answered 10/2, 2014 at 13:31 Comment(1)
This is what fixed it for meCajuput
S
13

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 :)

Silberman answered 21/1, 2014 at 14:5 Comment(3)
yes, the bug i had seems to be fixed in the new spring-commands-rspec version.Silberman
No, this solution is mere luck. This won't work if you don't restart spring.Pauiie
At the time of the question, just stopping spring was not working. I tried that 20 times until i found this solution.Silberman
E
10

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

spring stop

spring rspec

Then it should works as expected.

Edita answered 28/5, 2014 at 16:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.