[rspec-users] Why RSpec?

David Chelimsky dchelimsky at gmail.com
Wed Apr 22 10:25:57 EDT 2009


On Wed, Apr 22, 2009 at 9:03 AM, Phlip <phlip2005 at gmail.com> wrote:
> 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".

Agreed. That's partially resolved now and will be more fully resolved
in the not-to-distant-future.

> RSpec's original incarnation should have been like test-spec.

In terms of the runner, yes.

> 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 Rails).

Not sure what you mean here. RSpec interops w/ t/u. You can do that
explicitly outside rails, and it's implicit in rails. RSpec's
manipulation of test request/response in rails is there to support
component isolation, which rails does not.

> 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! }
>     end
>   end
>
> 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.

It's not just about syntax and structure. It's also about process.
Better failure messages, pending examples, and customizable output are
all things that aim to make it easier to develop software.

Cheers,
David

>
> --
>  Phlip
>  http://flea.sourceforge.net/resume.html
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list