# Why detest rspec? (was: community poll about testing and spe

**URL:** <https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241>\
**Category:** Rails\
**Created:** [July 24, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241 "2007-07-24T16:03:07Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/21 "2007-09-25T23:04:05Z")

</div>

s.ross wrote:

> This argument is the same one you could use to say “what can you write in  
> Ruby that you can’t write, nearly the same way, in C”?

Uh, in the same volume of code? At the same velocity?

–  
Phlip  
[http://www.oreilly.com/catalog/9780596510657/](http://www.oreilly.com/catalog/9780596510657/)  
^ assert\_xpath  
[O'Reilly Media - Technology and Business Training](http://tinyurl.com/23tlu5) ← assert\_raise\_message

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/22 "2007-09-25T23:04:59Z")

</div>

We could debate either side of the issue. I could say “with the same  
compactness? with equivalent performance characteristics?” but at the  
end of the discussion, it’s all about what clicks for you. If you are  
happy with asserts (like in C, hence my analogy), then use them. I  
believe the BDD people – and I count David among one of the most  
thoughtful of the bunch – have put a good deal of work into making  
the description of the spec as natural as possible. Again, it’s what  
reads naturally to you. If you don’t parse it naturally, then no  
prob. Also, make careful note of what David says about the failure  
messages. This was one of my biggest complaints with Test::Unit and  
the fix is pretty close to free with RSpec. The failures report  
pretty much in English and if they don’t I probably wrote the example  
wrong.

–s

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/23 "2007-09-25T23:04:10Z")

</div>

On 7/25/07, Faisal N Jawdat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Jul 25, 2007, at 11:50 AM, David C. wrote:
> 
> > RSpec supports this by trying to use words like “describe” instead  
> > of “TestCase” and “should” instead of “assert.”
> 
> As an aside, RSpec’s use of “should” may be confusing to anyone  
> coming from the networking world:
> 
> [RFC 2119 - Key words for use in RFCs to Indicate Requirement Lev (RFC2119)](http://www.faqs.org/rfcs/rfc2119.html)

☹

Can’t clarify everything for everybody I guess.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/24 "2007-09-25T23:08:06Z")

</div>

On 7/25/07, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> s.ross wrote:
> 
> > This argument is the same one you could use to say “what can you write in  
> > Ruby that you can’t write, nearly the same way, in C”?
> 
> Uh, in the same volume of code? At the same velocity?

OK, so what about python?

I think the point Steve was making was about “feel”, which is what  
Ruby and Rails are largely about. To me, there is a huge difference  
between this:

team.should have(11).players

and this

assert\_equal 11, team.players.size

And an even bigger difference in the output when these fail:

expected 11 players, got 10

vs

expected 11, got 10

Implementing these probably takes the same amount of time. A month  
later, seeing “expected 11 players” is VERY meaningful, especially  
when multiple failures appear due to a change you just made. If I see  
10 failures that all say “expected x things, got y”, then I have a lot  
more information right away about what went wrong than if I just see  
“expected x, got y”.

FWIW.

David

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/25 "2007-09-25T23:06:12Z")

</div>

Hi –

On Wed, 25 Jul 2007, Faisal N Jawdat wrote:

> On Jul 25, 2007, at 11:50 AM, David C. wrote:
> 
> > RSpec supports this by trying to use words like “describe” instead  
> > of “TestCase” and “should” instead of “assert.”
> 
> As an aside, RSpec’s use of “should” may be confusing to anyone  
> coming from the networking world:
> 
> [RFC 2119 - Key words for use in RFCs to Indicate Requirement Lev (RFC2119)](http://www.faqs.org/rfcs/rfc2119.html)

I don’t think that coming from the networking world means one can’t  
make the leap of imagination required to realize that the entire world  
does not speak in compliance with RFC2119 🙂 I wouldn’t worry about  
it for a second.

David

–

- Books:  
RAILS ROUTING (new! [http://www.awprofessional.com/title/0321509242](http://www.awprofessional.com/title/0321509242))  
RUBY FOR RAILS ([Ruby for Rails](http://www.manning.com/black))
- Ruby/Rails training  
& consulting: Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/26 "2007-09-25T23:09:13Z")

</div>

On 7/25/07, James M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Roderick: David C. might be a little miffed with your selective  
> quoting which makes it appear as if he doesn’t like RSpec…
> 
> David C. wrote:
> 
> > > I may be biased, but I would really like and have been looking for an  
> > > alternative BDD choice besides RSpec.
> 
> This was not written by David, but was written in response to an email from  
> him. The only clue to this is the level of indentation of the quoting.

Actually, this makes me laugh more than piss me off. But thanks for  
sticking up for me 🙂

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:11pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/27 "2007-09-25T23:11:57Z")

</div>

On Jul 25, 6:34 pm, Faisal N Jawdat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Jul 25, 2007, at 11:50 AM, David C. wrote:
> 
> > RSpec supports this by trying to use words like “describe” instead  
> > of “TestCase” and “should” instead of “assert.”
> 
> As an aside, RSpec’s use of “should” may be confusing to anyone  
> coming from the networking world:
> 
> [RFC 2119 - Key words for use in RFCs to Indicate Requirement Lev (RFC2119)](http://www.faqs.org/rfcs/rfc2119.html)

Fortunately, if you find “should” confusing or misleading you can  
write your examples such as this one:

it “should redirect to the home page after logging out”

like this instead:

it “must redirect to the home page after logging out”

Or using any other word or language you think is better. The language  
you employ in your examples is up to you, although the RSpec community  
does tend to use some widespread patterns, including the use of the  
word “should” in a way that is closer to the “standard English sense”  
rather than the “RFC-2119 sense”.

Cheers,  
Wincent

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:09pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/28 "2007-09-25T23:09:47Z")

</div>

@David:

Would you be kind enough to briefly explain what you perceive to be the  
advantages to RSpec? I’m really hoping for a good comparison of the two,  
so  
I can see if it’s worth investigating further. (I am writing a book that  
will include testing, and need more info). I’ve played with RSPec and  
haven’t really found anything I can’t do with test:unit… so that’s  
why  
I’m looking for more info. I’d really appreciate some input. I suspect  
that  
it’s much like TDD… you have to do it before you really appreciate it.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/29 "2007-09-25T23:12:00Z")

</div>

s.ross wrote:

> This argument is the same one you could use to say “what can you write  
> in Ruby that you can’t write, nearly the same way, in C”? Heck, they are  
> both TC general purpose computer programming languages. Ahhhh, but the  
> “feel” is different. That’s what I find sets RSpec apart, and if it  
> doesn’t click for you it might not _work_ for you.

Agreed. I also consider RSpec to be one of those most exciting things to  
pop up in the Ruby community since Rails. Our pure-Ruby libs are being  
spec’d (not tested) and we can pretty much run rm -rf test/ in our Rails  
applications.

It might not sit well with all, but the syntax is a great example of how  
great and expressive Ruby can be.

Robby

–  
Robby R.  
[http://www.robbyonrails.com/](http://www.robbyonrails.com/)

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/30 "2007-09-25T23:12:02Z")

</div>

On 7/26/07, Wincent C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > [RFC 2119 - Key words for use in RFCs to Indicate Requirement Lev (RFC2119)](http://www.faqs.org/rfcs/rfc2119.html)  
> > Or using any other word or language you think is better. The language  
> > you employ in your examples is up to you, although the RSpec community  
> > does tend to use some widespread patterns, including the use of the  
> > word “should” in a way that is closer to the “standard English sense”  
> > rather than the “RFC-2119 sense”.
> 
> Cheers,  
> Wincent

I’m pretty sure that he’s referring to  
foo.should == bar

However I have to say I think it’s an absurdly nitty “issue”

Pat

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/31 "2007-09-25T23:12:10Z")

</div>

On 7/25/07, Brian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @David:
> 
> Would you be kind enough to briefly explain what you perceive to be the  
> advantages to RSpec? I’m really hoping for a good comparison of the two, so  
> I can see if it’s worth investigating further. (I am writing a book that  
> will include testing, and need more info). I’ve played with RSPec and  
> haven’t really found anything I can’t do with test:unit… so that’s why  
> I’m looking for more info. I’d really appreciate some input. I suspect that  
> it’s much like TDD… you have to do it before you really appreciate it.

I don’t know that there is anything that you can’t do with test/unit -  
just that rspec comes w/ a lot of this stuff out of the box. And I  
think it is something experiential. Many people who really enjoy using  
RSpec say they were skeptical at first, but have grown to love it.

Here are some specific comparisons:

- dsl for expressing/organizing examples using strings

describe Thing do  
it “should do cool stuff” do  
…  
end  
end

vs

class ThingTest \<\< Test::Unit::TestCase  
def test\_should\_do\_cool\_stuff  
…  
end  
end

I find that this encourages better naming and organization.

- dsl for expressing expectations

team.should have(11).players

vs

assert\_equal 11, team.players.size

- better failure messages

expected empty? to return true, got false

vs

expected true, got false

- better reporting

Thing

- should do this
- should do that
- should do the other thing (FAILED - 1)
- should do even this (PENDING: Not Yet Implemented)

vs

…

There is also a nicely formatted HTML report out of the box:

[http://rspec.rubyforge.org/report.html](http://rspec.rubyforge.org/report.html)

- rspec\_on\_rails - component isolation allows you to test views before  
controllers or models even exist. This is VERY helpful when you’re on  
an XP or XP-like team.

I’m sure there’s more that I’m not thinking of right now. There’s also  
the “joy” factor. I find it a more joyful experience to use RSpec, for  
the reasons stated above and for reasons that you can only appreciate  
by exploring it.

Hope this helps.

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/32 "2007-09-25T23:20:07Z")

</div>

Pat M. wrote:

> > >
> 
> foo.should == bar  
> Ah, yes, you’re almost certainly right.

Well the solution to that is also only a step away (alias “should” and  
“should\_not” to whatever you want in your spec helper file). Of  
course, I wouldn’t actually recommend doing so, as it seems to be  
going against the grain for no real good reason.

Cheers,  
Wincent

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/33 "2007-09-25T23:20:44Z")

</div>

@David, @Kyle:

Great stuff. If you were going to expose people to tests, would you  
start  
with TDD and test:unit, or would you go right to BDD and RSpec?

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:12pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/34 "2007-09-25T23:12:12Z")

</div>

Brian H. wrote:

> @David:
> 
> Would you be kind enough to briefly explain what you perceive to be the  
> advantages to RSpec? I’m really hoping for a good comparison of the two, so  
> I can see if it’s worth investigating further. (I am writing a book that  
> will include testing, and need more info). I’ve played with RSPec and  
> haven’t really found anything I can’t do with test:unit…

And that’s as expected. As you’ll read in most intros to BDD, it’s the  
same practice as TDD, but with the focus shifted. Everything you can do  
with BDD can be done with TDD.

People seem to be expecting some sort of sea change in development  
practices, but that’s not going to happen here. And from what I’ve read,  
it was never intended to.

It’s a small tweak, to refocus TDD practitioners a slight bit. They  
think it produces better specs/tests, not because it’s something that  
couldn’t be done before, but because it’s now more obvious what you  
should be doing.

If TDD has always worked well for you (as I’ve read before, “if you’ve  
been doing it right all along”), then great, stick with it.

But the very simple terminology changes are what made the point of TDD  
finally click for me.

As for rspec specifically? It does what I need it to, produces  
phenomenally legible specs, and then stays out of the way.

Kyle

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/35 "2007-09-25T23:20:47Z")

</div>

> …  
> I first saw RSpec in one of the tutorials at RailsConf this year. The  
> positive reinforcement from seeing what you were testing each time was  
> compelling. I also find seeing the list of tested behaviors often  
> suggests to me the next test/feature that needs to be added to the  
> project. (Now if I could just get my rspec.conf file to be used so I  
> don’t have to pass ‘-f specdoc’ each time I run my tests.

> - rspec\_on\_rails - component isolation allows you to test views before  
> controllers or models even exist. This is VERY helpful when you’re on  
> an XP or XP-like team.

David, could you expand on this? Or post a link to docs or a tutorial  
or blog post about testing views with RSpec.

–  
Cynthia K.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/36 "2007-09-25T23:21:30Z")

</div>

On 7/27/07, Cynthia K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> David C. wrote:
> 
> > - rspec\_on\_rails - component isolation allows you to test views before  
> > controllers or models even exist. This is VERY helpful when you’re on  
> > an XP or XP-like team.
> 
> David, could you expand on this? Or post a link to docs or a tutorial  
> or blog post about testing views with RSpec.

[http://blog.davidchelimsky.net/articles/2006/11/06/view-spec-tutorial](http://blog.davidchelimsky.net/articles/2006/11/06/view-spec-tutorial)  
[http://rspec.rubyforge.org/documentation/rails/writing/views.html](http://rspec.rubyforge.org/documentation/rails/writing/views.html)  
[http://rspec.rubyforge.org/rdoc-rails/index.html](http://rspec.rubyforge.org/rdoc-rails/index.html)

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:22pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/37 "2007-09-25T23:22:06Z")

</div>

On 7/25/07, Brian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> @David, @Kyle:
> 
> Great stuff. If you were going to expose people to tests, would you start  
> with TDD and test:unit, or would you go right to BDD and RSpec?

Green field? i.e. no experience with testing at all? Definitely RSpec.

Beyond that, it depends on myriad factors, mostly boiling down to what  
is going to be most pragmatic for the team based on their level of  
experience with Ruby, testing in general, other frameworks, etc. I’d  
always prefer RSpec because, well, I prefer it. But sometimes going w/  
test/unit could be more pragmatic, at least in the short run.

David

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/38 "2007-09-25T23:36:34Z")

</div>

Look here:

[http://rspec.rubyforge.org/documentation/rails/writing/views.html](http://rspec.rubyforge.org/documentation/rails/writing/views.html)

The idea is that you can mock enough to populate the view data  
allowing you to design from the “outside in.” Basically mock up your  
UI, do it in RHTML (or whatever markup you like), and write specs for  
that.

---

<div class="post-metadata">

**Author:** ![crucoba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e8c25b/32.png) [@crucoba](https://www.ruby-forum.com/u/crucoba)\
**Post date:** [September 25, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241/39 "2007-09-25T23:36:29Z")

</div>

Brian H. wrote:

> @David, @Kyle:
> 
> Great stuff. If you were going to expose people to tests, would you  
> start with TDD and test:unit, or would you go right to BDD and RSpec?

Our team adopted RSpec about a year ago and we’ve been through several  
projects entirely without Test::Unit. If someone has never had any  
experience with TDD, then I would advocate learning through BDD… and  
would recommend RSpec as the framework to learn it with.

On a side note. JRuby 1.0 will come with two gems.

Rake and RSpec.

Yes… people are using it in the real world and I can testify on it’s  
behalf in court. It’s elegant. Our developers _LOVE_ it. I love it. Even  
our Interaction Designers have picked up on the lingo and use  
“should”-style language in their interface specifications, which  
translates nicely into our implementation process.

RSpec ftw!

Robby

–  
Robby R.  
[http://www.robbyonrails.com/](http://www.robbyonrails.com/)

> **[Planet Argon](https://www.planetargon.com/)**
>
> Planet Argon is a Ruby on Rails development agency specializing in maintenance and support for existing Rails apps. Based in Portland, OR, Planet Argon has been a member of the Rails community since 2004.

[Previous page](https://www.ruby-forum.com/t/why-detest-rspec-was-community-poll-about-testing-and-spe/110241.md?page=1)
