[rspec-users] Why RSpec?

Phlip phlip2005 at gmail.com
Wed Apr 22 10:03:44 EDT 2009

Amos King wrote:
> I like Shoulda.  Sometimes I like plain old Test::Unit.  Cucumber
> gives me a different thought process.
> I'd just like to hear some thoughts on why RSpec?  What does it buy me
> that I can't get with Shoulda?  I just can't seem to think in RSpec.
> Where is there a good example of RSpec tests that will help me grasp
> the right path?

RSpec is not DRY with respect to Test::Unit. A bit of "not invented here".

RSpec's original incarnation should have been like test-spec. I suspect new 
syntax built within Test::Unit would have save us from tedious hours of 
reinventing all the test fixtures (such as the mock @request and @response for 

The only design point for the new syntax I can see is this:

    context 'general' do
      setup{ general }
      specify{ something general }
      specify{ another general thing }
      context 'specific' do
        setup{ specific }
        specify{ test general and specific together }
        specify{ test specific and general together! }

The alternative in TestCase was only either a setup() that builds both 'general'
and 'specific', when two cases don't need it, or duplicating 'specific' into two
test cases, or merging the 'specific' setup into a global 'assemble_specific'
method yadda yadda yadda. Nesting the contexts lets them share their setups, so
the contexts are much easier to mix and match.


More information about the rspec-users mailing list