Provide command to run specific test? #113

m-o-e opened this Issue Jun 9, 2012 · 12 comments


None yet
7 participants

m-o-e commented Jun 9, 2012

It would be nice if there was a way to run specific tests only, akin to rspec -e.

I.e. something to the tune of (in the CLI): rspec -e "match me"

Which would pass -e to rspec and consequently only run tests that match the string "match me".

Even nicer if we could temporarily scope the automatic runs, i.e. with something like: rspec scope -e "match me"

All subsequent runs would then only perform the "match me"-tests, until a different scope is given or the scope is removed with rspec scope.

Currently I keep a second shell window open in addition to guard where I run individual tests as needed (because the full suite takes too long for quick iteration). It would be nice to have that functionality baked right into guard for convenience.


rymai commented Jun 10, 2012

Hum, interesting idea, we could probably start thinking about "guard plugins' custom interactive commands" so that each guard plugin could define its own commands in the interactor (the commands would always start with the name of the guard plugin, e.g. rspec <command>)...
In that case we should create a new disussion in the Guard issue tracker.

What do you think @guard/core-team ? Do you think it might be useful or overkill?


thibaudgg commented Jun 10, 2012

Yeah that an interesting idea, this is definitely something that need to be added first on Guard side. Maybe we could add this with the new support of coolline (and maybe Ruby 1.9 syntax only).

👍 really want it!


netzpirat commented Nov 14, 2012

Starting with Guard 1.5.0, this can be achieved by implementing a Pry command. Guard itself has a change command that can serve as a starting point or you can extend the change command itself to to the filtering of existing files and pass them as changed files.

@netzpirat can you show quick example?


netzpirat commented Nov 14, 2012

All Guard interactor commands are Pry commands:

pjg commented Nov 22, 2012

This is a really cool idea! What I would like to be possible is to have two different commands to running your test suite:

  • one command by default would only run your fast specs (so for example all specs not tagged js: true) (this could be the default, executed with <enter>) (I believe this is already possible with cli options)
  • the other command would run your whole suite (this could be bound to f or a) (this would be the new custom command, passing in different cli options)

That would be really really helpful.

thibaudgg closed this Apr 6, 2013

aspiers commented Aug 26, 2013

@pjg That's almost exactly what I need - well actually I want to run all specs tagged focus: true. I read @netzpirat's comment above, but it's still not at all clear to me how or even whether this is achievable.

If it is achievable right now, please could this issue be reopened until it is documented how to do this? Until it's documented, I think it is currently too hard for most users to achieve. (And if it's not achievable right now, I'm not sure why this issue was closed.)


pjg commented Aug 26, 2013

@aspiers I'm not sure exactly what you want... perhaps this will help you?

aspiers commented Aug 26, 2013

@pjg I'm already aware of that technique. But I want to be able to do that from inside guard! Isn't that the whole point of this github issue? Thanks ...


thibaudgg commented Aug 27, 2013

@kossnocorp have you something to share that works with Pry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment