Last Updated: February 25, 2016
·
1.125K
· mcansky

Running specifing specs with rspec 1.x

Some of us are busy maintaining old Rails apps test covered with Rspec 1.x while a fork is being updated ...

When doing so, some spec files might be big and you might be waiting for them to run when you just change or add one little example or context in it.

With rspec 2 there is that tag thing, with rspec 1 you are left with ... well example titles matches and line numbers.

Yes you can limit your spec run to a single example or context by passing either :

  • -e arg followed by the complete title of your example
  • :X where X is a line number just after the filename

look :

rspec spec/some_spec.rb -v "is an awesome test"
# it "is an awesome test" do ...

rspec spec/some_spec.rb:22

You can use the first to trigger specific examples, the later will trigger either examples or context (with multiple examples in it).

source : http://stackoverflow.com/questions/5069677/how-do-i-run-only-specific-tests-in-rspec