Coder Social home page Coder Social logo

spring-commands-rspec's Introduction

spring-commands-rspec

This gem implements the rspec command for Spring.

Usage

Add to your Gemfile:

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

If you're using spring binstubs, run bundle exec spring binstub rspec to generate bin/rspec. Then run spring stop to pick up the changes.

spring-commands-rspec's People

Contributors

0x616e676572 avatar jonleighton avatar monkbroc avatar stgeneral avatar take avatar trliner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-commands-rspec's Issues

rspec does not find any examples

10.9.2
rails -v
4.0.4
rpsec -v
3.0.0beta2

when i run rpsec spec/ it shows this
No examples found.

Finished in 0.00012 seconds
0 examples, 0 failures

Randomized with seed 24430

Load time incorrect with Spring

Standard practice now with Rails 4 seems to be to use Spring with spring-commands-rspec to generate bin/rspec. In rspec-core, because @load_time gets set in Reporter#start before Spring forks the rails process, the load time only gets set once, when the Spring server first starts. Every time I run my specs with bin/rspec, I get output like this:

Finished in 0.01662 seconds (files took 85 minutes 45 seconds to load)
12 examples, 0 failures, 3 pending

It was really just 85 minutes ago that Spring started.

When running rspec directly (not using the binstub provided by this gem), I do not have this issue.

I originally brought up the issue rspec/rspec-core#1574 with the rspec-core team, and we agreed that this would be better addressed by the launcher. @myronmarston pointed out that rspec exposes an attribute that alternate runners can set to the current time when they begin the setup for the next run.

I think this gem probably would be the most appropriate place to address this issue, but it also seems that the API provided by Spring::Commands is somewhat limited and may possibly not support what we need to do. You certainly would know better than me though. What are your thoughts?

key not found "rspec"

Hi I'm getting the following error when trying to run
$ bin/rspec

and getting the following error:
spring-1.1.3/lib/spring/commands.rb:20:in `fetch': key not found: "rspec" (KeyError)

the problem is in this function (in spring/commands.rb)

def self.command(name)
commands.fetch name
end

so rspec is not registered in commands for some reason.
I followed all the steps to install, don't know what to do.
I'm using spring 1.1.3, spring-commands-rspec 1.0.2, rspec-rails 3.1.0 and rspec-core 3.1.5

thanks.

spring-commands-rspec don't work

Hi!

I've installed both spring (1.3.5) and spring-commands-rspec (1.0.4)
And it seems I've met the troubles with run spring server for rspec. Please review the log

sergey@Pisuk:~/projects/fasteria$ time bin/rake db:migrate

real    0m2.013s
user    0m0.092s
sys 0m0.008s
sergey@Pisuk:~/projects/fasteria$ time bin/rake db:migrate

real    0m0.304s
user    0m0.087s
sys 0m0.008s

# it's worked

sergey@Pisuk:~/projects/fasteria$ time bin/rspec spec/models/user_spec.rb 
...

Finished in 1.1 seconds (files took 3 seconds to load)
3 examples, 0 failures

real    0m4.274s
user    0m0.087s
sys 0m0.008s
sergey@Pisuk:~/projects/fasteria$ time bin/rspec spec/models/user_spec.rb 
...

Finished in 1.12 seconds (files took 2.98 seconds to load)
3 examples, 0 failures

real    0m4.261s
user    0m0.088s
sys 0m0.008s
# doesn't work

Here is my Gemfile:

group :development do
  ...
  gem 'spring-commands-rspec'
  gem 'spring'
end

I use rvm -v 1.26.11, ruby -v 2.2.1p85, rails -v 4.2.0, ubuntu 14.04.

Here is output of sprng status command:

Spring is running:

20677 spring server | fasteria | started 7 mins ago
20685 spring app    | fasteria | started 7 mins ago | development mode                                             
21872 spring app    | fasteria | started 6 mins ago | test mode 

What's going wrong? P.S I have ran spring stop a lot of times

Restart required to pick up new commands

I have an app that I use spring with. I recently upgraded/reinstalled all my gems. After I did so I use my sprec (aka spring rspec) command only for it to complain that spring rspec doesn't exists. I then added the gem to my gem file, ran bundle install and tried again. Although the help text said spring rspec was an option, it did not work until I ran spring stop. After which, it worked fine.

shoulda-matchers not included (Rails 4.1)

I've upgraded to Rails 4.1 and had problems running rspec with spring. It threw errors which indicated that shoulda-matchers gem was not loaded.

Failures:

  1) Post should have many :comments
     Failure/Error: it { should have_many(:comments) }
     NoMethodError:
       undefined method `has_many?' for #<Post:0x007ff923bf57d8>
     # ./spec/models/post_spec.rb:11:in `block (2 levels) in <top (required)>'
     # -e:1:in `<main>'

  2) Post 
     Failure/Error: it { should belong_to(:author) }
     NoMethodError:
       undefined method `belong_to' for #<RSpec::Core::ExampleGroup::Nested_1:0x007ff92854b298>
     # ./spec/models/post_spec.rb:10:in `block (2 levels) in <top (required)>'
     # -e:1:in `<main>'

  3) Post 
     Failure/Error: it { should validate_presence_of :title }
     NoMethodError:
       undefined method `validate_presence_of' for #<RSpec::Core::ExampleGroup::Nested_1:0x007ff9285482c8>
     # ./spec/models/post_spec.rb:7:in `block (2 levels) in <top (required)>'
     # -e:1:in `<main>'

I've tried changing my Gemfile and got it working by manually requiring the gem in spec_helper.rb.

# Gemfile
group :test do
  gem 'shoulda-matchers', require: false
end
# spec/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rails'
require 'webmock/rspec'
require 'email_spec'
# require 'rspec/autorun'
require 'shoulda-matchers'
...

This way the gem is loaded and rspec runs without problems. However I believe this should be fixed somehow. Not sure if this is spring-commands-rspec, spring or even rails related problem.

RSpec not loading its binstub

Currently if I do bin/rspec then Spring is used as expected, but simply rspec doesn't make use of Spring. rails, in contrast, does respect its binstub (I tested by adding something in the binstub). My current workaround is zsh-autoenv, but not that neat.

I am not sure whether this issue belongs to this repository or to RSpec. If the latter, then which repository of @rspec?

Not passing environment variables

It seems I can't pass environment variable through spring rspec. For exmaple,

AUTODOC=1 spring rspec --color spec/

the AUTODOC is not received in rspec.

Spring is not using the bundled version of Rspec

I have two versions of rspec and my Gemfile.lock especifies version ~> 2.9.0, but spring-commands-rspec uses the older version

> gem list rspec                                              
*** LOCAL GEMS ***                                               

rspec (2.99.0)
rspec-collection_matchers (1.1.2)
rspec-core (2.99.2, 2.14.8)
rspec-expectations (2.99.2, 2.14.5)
rspec-mocks (2.99.3, 2.99.2, 2.14.6)
rspec-rails (2.99.0, 2.14.2, 2.14.1)
spring-commands-rspec (1.0.4)

FYI: On Rails 7 & Ruby 3, $ rails console occurs an error

On Rails 7 and Ruby 3, executing $ rails console occurs this error.

$ bin/rails console
/myapp/vendor/bundle/ruby/3.1.0/gems/spring-2.1.1/lib/spring/application.rb:103:in `block in preload': undefined method `mechanism=' for ActiveSupport::Dependencies:Module

        ActiveSupport::Dependencies.mechanism = :load
                                   ^^^^^^^^^^^^ (NoMethodError)

I removed gem 'spring-commands-rspec', spring and spring-watcher-listen from Gemfile and $ bundle install so it worked correctly.

Undefined method `register_command' for Spring:Module when running `rails s`

Using spring 0.9.0 and spring-commands-rspec, I can no longer run a rails server. I've tried the following on a completely empty new Rails 4.0 app:

  • Using Rails' default bin/rails file as well as the one generated by spring binstub rails
  • Doing it with and without a config/spring.rb file requiring spring-commands-rspec

Commands that use spring (such as a Rails console or running RSpec) work just fine, it's only launching the server that dies.

Relevant Gemfile portion:

group :development do
  gem 'spring'
  gem 'spring-commands-rspec'
end

Error:

dylans-mpb ~/dev/spring_example bin/rails s
/Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-commands-rspec-1.0.0/lib/spring/commands/rspec.rb:13:in `<module:Commands>': undefined method `register_command' for Spring:Module (NoMethodError)
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-commands-rspec-1.0.0/lib/spring/commands/rspec.rb:2:in `<module:Spring>'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/spring-commands-rspec-1.0.0/lib/spring/commands/rspec.rb:1:in `<top (required)>'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:81:in `require'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:81:in `rescue in block in require'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/dylan/dev/spring_example/config/application.rb:7:in `<top (required)>'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
    from /Users/dylan/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Once I remove the spring-commands-rspec line from my Gemfile, everything works perfectly (except using spring for RSpec, of course)

Doesn't work when not in the Gemfile

I might be doing something wrong, but I've tried running spring rspec spec in a project that doesn't have spring in its Gemfile and I'm getting The 'rspec' command is not known to spring..

If I add both to a Gemfile, generate binstubs and then run ./bin/spring rspec spec everything works as expected.

Is this expected or am I doing something wrong?

binstub doesn't seem to be working

I installed spring-commands-rspec, stopped Spring, issued a spring binstub rspec, it created it with this content:

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

But now each time I run rspec spec it doesn't start Spring. Not using the binstub works fine (spring rspec spec).

Doesn't recognize `rspec`

After I installed and generated binstub, then there is an error when I run bin/rspec:

 ./bin/rspec spec
ruby: warning: RUBY_FREE_MIN is obsolete. Use RUBY_GC_HEAP_FREE_SLOTS instead.
Version: 1.1.1

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
/Volumes/Document/Projects/Steve/petto/.gems/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load': cannot load such file -- /Volumes/Document/Projects/my_project/rspec (LoadError)
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each'
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files'
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run'
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
        from /Volumes/Document/Projects/my_project/.gems/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'

I'm using: Rails 4.0.2, RSpec 2.14.1

`spring rspec` doesn't respect rspec's default file matching pattern

OS X: 10.8.5

∴ rails -v
Rails 4.1.0.beta1

∴ glg spring
spring (1.1.0)
spring-commands-rspec (1.0.1)

∴ rspec -v
2.14.7

Running a bare rspec command correctly picks up all example files matching the pattern: spec/**/*_spec.rb (per the spec).

∴ rspec
.........

Finished in 0.89628 seconds
9 examples, 0 failures

However, running spring rspec either does nothing or doesn't find the examples. Here I run spring rspec 3 times:

∴ spring rspec
projekt/ on rails_4.1.0.beta1
∴ spring rspec
projekt/ on rails_4.1.0.beta1
∴ spring rspec
projekt/ on rails_4.1.0.beta1
∴ No examples found.


Finished in 0.00033 seconds
0 examples, 0 failures

I've also tried adding --default_path specs to my .rspec file, with the unexpected behavior persisting.

Any ideas what I'm doing wrong or how I can fix it? I'm more than happy to contribute, I just need a little direction. Thanks.

Running rspec with arguments

I'm not sure if I'm doing something wrong, but when running bin/rspec generated by this gem with any command line arguments, it seems to never find the rails spec dir or anything in it, and just runs 0 examples. I tried running rspec -e "my string" and rspec --deprecation-out deprecs.txt and I get 0 examples, 0 failures. The command works with the same arguments when run without spring. Also running rspec without arguments seems to pick up all the specs. I did restart spring.

spring-commands-rspec 1.0.2
rspec-rails 2.99.0
rspec 2.99.1
spring 1.1.3
rails 4.1.4

RSpec with bin/spring broken after upgrading and rolling back from RSpec 3.1

I recently tried upgrading to Rspec 3.1, and since I have used Expectations 3.0 for awhile I didn't have to rewrite my tests.

But after the upgrade my tests would pass if I ran rspec spec/, but about half would fail if I ran bin/spring rspec spec/ I also had made changes to the way I was testing Sidekiq workers, so that is another possible cause for this.

I rolled back to a previous known good app with no RSpec 3.1 (2.14.1 instead) and removed the spring gem and regenerated the binstubs, but all to no avail, spring would either hang when I ran RSpec or half my tests would fail. Without spring, all my tests passed.

With Sidekiq I am using the inline option, which is documented here. I haven't tried different options with this, it could be related.

I love spring, but I am going to go back up to RSpec 3.0. I will hope you have some ideas about how I could trouble shoot this. Thanks in advance for the help.

using format (-f) option creates duplicate output

happens with both spring rspec and ./bin/rspec

happens with both released gem and current master branch aebd5d8

# spring rspec spec/models/app_spec.rb

Run options:
  include {:focus=>true}
  exclude {:broken=>true}

All examples were filtered out; ignoring {:focus=>true}
....

Finished in 0.14627 seconds (files took 0.23199 seconds to load)
4 examples, 0 failures

Randomized with seed 64426
# spring rspec -f progress spec/models/app_spec.rb
Run options:
  include {:focus=>true}
  exclude {:broken=>true}
Run options:
  include {:focus=>true}
  exclude {:broken=>true}

All examples were filtered out; ignoring {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
........


Finished in 0.15579 seconds (files took 0.27696 seconds to load)
4 examples, 0 failures

Finished in 0.15579 seconds (files took 0.27696 seconds to load)
4 examples, 0 failures

Randomized with seed 64426


Randomized with seed 64426

without spring:

# bundle exec rspec -f progress spec/models/app_spec.rb 
Run options:
  include {:focus=>true}
  exclude {:broken=>true}

All examples were filtered out; ignoring {:focus=>true}
....

Finished in 0.11127 seconds (files took 10.19 seconds to load)
4 examples, 0 failures

Randomized with seed 54966

Complexity of install, using cucumber or rspec

Previously I installed spring in my global gemset then created a couple of aliases to run cucumber and spec.

Now I have to install 3 different gems.

In addition

  1. It now seems that I can't install the rspec gem without adding to my Gemfile, as it needs require false
  2. I have to add a config file to each rails app to be able to use spring

This seems like a big step backwards in making spring a tool I can use for all my rails projects (adding it to the 50 or so existing projects I have is just such a pain now)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.