Forum: RSpec Specs for RSpec Matchers and Helpers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F85bacbbd4814799d4526b3e35a431df?d=identicon&s=25 Brandon Olivares (Guest)
on 2009-04-15 16:58
(Received via mailing list)
Hi,

I've been extracting a lot of code out of my specs into their own
matchers,
helpers, and macros.

I notice that the plugins that have their own specs, such as
rspec-rails,
and even RSpec itself, have specs for the matchers and helpers. Is this
generally a good thing to do, or is it unnecessary?

Brandon
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-04-15 17:06
(Received via mailing list)
On Wed, Apr 15, 2009 at 4:52 PM, Brandon Olivares
<programmer2188@gmail.com>wrote:

> Hi,
>
> I've been extracting a lot of code out of my specs into their own matchers,
> helpers, and macros.
>
> I notice that the plugins that have their own specs, such as rspec-rails,
> and even RSpec itself, have specs for the matchers and helpers. Is this
> generally a good thing to do, or is it unnecessary?
>

Overkill, unless they are really complex, which they shouldn't be. Usage
of
the matchers in specs should be good enough. If it isn't your matchers
are
too complex. Strive for cyclomatic complexity of 1 in *all* test code.
(no
branches).

Aslak
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2009-04-15 17:36
(Received via mailing list)
On Wed, Apr 15, 2009 at 7:52 AM, Brandon Olivares
<programmer2188@gmail.com> wrote:
>
> I've been extracting a lot of code out of my specs into their own matchers,
> helpers, and macros.
>
> I notice that the plugins that have their own specs, such as rspec-rails,
> and even RSpec itself, have specs for the matchers and helpers. Is this
> generally a good thing to do, or is it unnecessary?

The main difference is that they ship their matchers and you don't. If
their matchers have bugs, then their product has bugs. Not necessarily
so with your matchers.

In general, test code is simpler and more obvious than the code it
tests. So we don't have to test our tests. But it certainly doesn't
hurt, and if doing so increases the comfort level to a desired level,
then by all means do it.

Finally, much code can benefit from TDD, including matchers.

///ark
This topic is locked and can not be replied to.