Beginning with BDD: Rspec or Cucumber? What is better documented?

Hey everybody

I'm sorry, I know that this question seems to arise every few moments,
but I
think in my case it's a bit special (but doesn't everybody?).

Well, I'm working with RoR on a private level since v1.0, and my
knowledge about both Ruby and Rails are on a basic level (but definitely
does exist), but I'm in no means near being an expert yet.

In june, I will start with my first tenure in a company which uses
Rails, so I'm on my way to become a pro user, and I'm really, really
happy about that (byebye, PHP and Java!). It's sort of a startup company
which already is working on a small Rails app since some time, but until
now, testing has been neglected a bit. So I decided to become the person
responsible for our testing concept, but as I'm coming from cakePHP, I
only have experience in plain unit and functional testing using
SimpleTest, a quite basic testing framework for PHP. So now I want to
dig into more advanced techniques and frameworks for Rails, and
obviously there are quite a few of them, so I have to decide which one
to use and stick with.

I've come down to two very interesting frameworks: Rspec and Cucumber.
Both of them seem to be very world-proven and useful. But now I don't
really know for which I should go for our project.

What I'd like to do, is to have a good book about a good BDD-framework,
which guides me through the learning process comprehensively, so I
become a pro-tester really quick. I found the following two interesting
books:

The RSpec Book: Behaviour Driven Development with RSpec, Cucumber, and
Friends
http://www.amazon.de/gp/product/1934356379/ref=s9_simh_gw_p14_d1_g14_i3?pf_rd_m=A3JWKAKR8XB7XF&pf_rd_s=center-2&pf_rd_r=1KW9ABVTJ32QSGHJWNM4&pf_rd_t=101&pf_rd_p=463375173&pf_rd_i=301128

The Cucumber Book: Behaviour-Driven Development for Testers and
Developers
http://www.amazon.de/The-Cucumber-Book-Behaviour-Driven-Development/dp/1934356808/ref=pd_sim_eb_4

I think I will go for Cucumber, because the book is very current (march
2012) compared to the Rspec book (december 2010). Also, the Cucumber
book seems to be more focused on only cucumber, whereas the Rspec book
more seems to be like an overview over different testing frameworks
(including Cucumber).

So what do you think? Am I on a good way? Or would you guys (who have a
lot more experience in testing and the current state of testing
frameworks and their corresponding literature) suggest to do something
else?

Thanks a lot for your time and your opinion!
Josh

I think you should use cucumber and rspec together! If you want to do the out side in terminology like in rspec book, cucumber will handle easily with the integration’s tests! I used to use cucumber and rspec to do tests in my application but in my new project we are using just rspec for all tests and factory girl to work with factories! Rspec with selenium is a great deal to make some integration tests! I think if you need to show some histories to you client or maybe describe some behavior on your app in plain text you should use cucumber but if it is not a requirement, be happy with rspec and selenium, or maybe potergeist to handle with JavaScript without the browser pump in your screen !

Hope it helps

Regards

Thank you for your opinion, thiagocifani.

This sounds interesting. But I fear a bit that it's too much to dive
into at one time if I don't concentrate on one single framework. Do you
think different? As said before, I don't really have an idea about
anything yet, so maybe it truly IS a good idea to start with everything.

But then maybe the RSpec book would be the better option, although it's
already 1.5years old?

http://www.amazon.de/The-RSpec-Book-Behaviour-Development/dp/1934356379

Joshua Muheim wrote in post #1061798:

This sounds interesting. But I fear a bit that it's too much to dive
into at one time if I don't concentrate on one single framework. Do you
think different? As said before, I don't really have an idea about
anything yet, so maybe it truly IS a good idea to start with everything.

The thing is that it's not a matter of choosing between RSpec and
Cucumber. They are two very different tools, designed to solve different
problems in different ways.

It would be a little bit like choosing between a hammer and a screw
driver. You might be able to force one tool to do the other one's job,
but it won't be nearly as effective. If you want to drive a screw use a
screw driver, if you want to drive a nail use a hammer. If you want to
write low level specs (unit tests) use RSpec if you want to write a
user story (customer acceptance test) use Cucumber.

The two are designed to work together to cover all the different types
of specs/stories you need to prove your application is performing to
those specifications.

Choosing which one to learn first also depends on your situation. It's
not like one is more complicated to learn and understand than the other.
It depends a lot on your own particular needs.

I personally find RSpec has met the majority of my needs, but my
situation may be different than yours. For the apps I've written in
Rails the customer/stake holder was me. I didn't have a need to describe
the application in high level user stories. I was more interested in the
low level unit specs.

But then maybe the RSpec book would be the better option, although it's
already 1.5years old?

So, It's not like RSpec is going to change in drastic ways from one year
to the next. My recommendation would be to find the exact version of
RSpec being used by the book and install that version. Learn the basics
and get comfortable with the concepts. Once you get comfortable with
that version, then go out and research the differences between that
version and the latest release. The changes will not likely be
overwhelming once you understand the basics.

Thank you for this very useful reply, Robert.

I decided to go with the RSpec book now, because from its foreword I can
tell that it's not only about RSpec, but it's also about Cucumber (and
many other accompanying tools, too), so I'm quite confident I will get a
good introduction in both tools and will know which one I want to use
(or even both).

And you're right about the date of the book - the basic ideas don't
happen to change that fast, and it won't be too tricky to catch up with
the new features after I grasped the basic concepts.

Thanks again, I'm confident that I'm on a good way now!

I’d recommend learning RSpec first, as Cucumber is an additional abstraction above. Think of it this way:

RSpec: reads more like code, but you can see exactly which methods are being called, etc.

Cucumber: reads more like English, but you have to maintain a file to “translate” from the code

Cucumber is often used when interacting with clients who don’t necessarily know how to code, as they will be able to understand the plain language and can even help create some of the tests themselves.

Hey guys.

I finally got "The RSpec book" and afte reading some pages I'm really
confident it was the right choice. I already learned that Cucumber first
was planned to be a part of RSpec, and so it still is an integral part
of it. The book teaches how to use both of them and in which areas one
should use the one or the other. This is exactly what I've been looking
for.

Thanks again for your replies. I'm enjoying diving into BDD! :slight_smile: