Focusing on a Single Test

47 views
Skip to first unread message

Andrea Reginato

unread,
Jan 2, 2014, 10:36:47 AM1/2/14
to rs...@googlegroups.com
Hi everyone, 

i was wondering if there is or if anyone could find useful the usage of 
code based sulutions to run a single test. Let me explain.

Using Guard and Spork (or Spring) when write some specs, all the specs
in a specific file are executed. Some times, I've different tests on a single
file and it takes several seconds. I find my self commenting the tests that
passes and I leave the new ones uncommented. 

It works, but it's not productive. I know I can run a specific test frome the
command line using the -e option, but this is not the solution I need, as far
as I use Spork and the load time is pretty long.

I really love the approach taken from Jasmine and Mocha in the JS world.
For example, using Jasmine, if I change it to iit, I'll run only one test. Here
a more complete description  
               
                                JASMINE                              MOCHA
Focus on a single test         change it to iit              change it to it.only
Skip a test                 change it to xit                     change it to it.skip
Focus on a describe block       change describe to ddescribe      change describe to describe.only
Skip a describe block         change describe to xdescribe      change describe to describe.skip

My queston is: do you know any solution which can be used in Rspec to 
simulate this behaviour. I couldn't find it. 

Thanks a lot.

Myron Marston

unread,
Jan 2, 2014, 11:18:29 AM1/2/14
to rs...@googlegroups.com
You can configure RSpec to run only examples tagged with a specific key, such as `:focus`:


In addition, RSpec 2.14+ has `fit` as an alias for `it "...", :focus => true`:


There's also `xit`, which makes an example temporarily pending:


At the example group level, there are not yet shortcuts like `xdescribe` or `fdescribe`, but they're planned for RSpec 3:


HTH,
Myron
 

Andrea Reginato

unread,
Jan 2, 2014, 11:29:29 AM1/2/14
to rs...@googlegroups.com
Thanks a lot fot the complete answer. I'll try them out.
Reply all
Reply to author
Forward
0 new messages