RSpec 2.8: The Popular Ruby BDD Tool Goes Supersonic
RSpec 2.8 has been released, along with rspec-rails 2.8.1 for the full Rails 3.x integration experience.
RSpec is a BDD-focused testing tool that's particularly popular in the Rails world where everyone except DHH is using it (if you believe the hoopla). RSpec has faced accusations of being less than speedy in the past, but it seems 2.8 has had a performance firework shoved up its tailpipe:
David Chelimsky, the creator of RSpec, also notes that in RSpec 2.8:
- the documentation has been significantly improved
- there's improved support for tags and filtering
- random example running order support (with user definable seed)
rspec --init
will create aspec
directory and some starter code on a blank project - ideal for Ruby library development!
Overall, 2.8 seems like a good step forward, and if you've been feeling a little constipated in the spec running department lately, RSpec 2.8 might help you get things flowing again (though as with Ruby 1.9 vs 1.8, your mileage may vary depending on your usage.)
January 7, 2012 at 6:05 pm
I've been using minitest/spec for a while without much problem. Is there a reason for rspec's popularity besides the fact it has automagical integration with rails?
January 7, 2012 at 7:49 pm
It's been around longer, includes a mature mocking and stubbing system (a common complaint I've seen from minitest/spec newbies), has a better reporting and output system, among other things.
January 7, 2012 at 7:59 pm
Also there's a book for RSpec (which is actually quite good). In my experience (yours may differ) most Ruby developers use RSpec so it is quite easy to get help, exchange views etc.
It's a great project overall, well done for the 2.8 release.
January 8, 2012 at 9:34 am
Just for the record: I don't use rspec either, nor any other magic, fancy, bloated test framework suite. I'm with dhh here. test/unit or minitest do the job just fine.
January 8, 2012 at 6:19 pm
I get exactly the same speed at rspec 2.6.0.
January 8, 2012 at 11:26 pm
I don't use RSpec, pretty much for the reason janfri gave in the DHH post, but why has its performance improved? I assumed that load times are (or at least were until recently) the main bottleneck in any testing framework.
January 10, 2012 at 11:30 pm
@Andrew Grimm, the RSpec team reimplemented all the DSL matchers to use classes. Check out the benchmark here to see the speed differences: https://github.com/rspec/rspec-expectations/blob/master/benchmarks/matcher_dsl_vs_classes.rb
January 13, 2012 at 4:10 pm
agreeing with chrismealy, same results as 2.6.0. i never updated to 2.7.0 because it ran so slow (~60% increase)
February 25, 2012 at 11:29 am
When I read this I was jumping to upgrade hoping to speed up an app's test suite but.. ouch, I had already upgraded :(