cucumber vs. RSpec

I want to start diving into BDD. I have never used TDD before and am not sure if I should start by learning RSpec and then jump to Cucumber or just go straight to using Cucumber.

I have been reading on the internet about both and it seems to me that Cucumber could be a 'replacement' for RSpec. Am I right or should be one used for certain things and the other one for others?

Thanks in advance.

Pepe

Yes, cucumber and rspec are both used for BDD.

I personally prefer Cucumber, but some people find it offputting, and prefer their tests to be less english, more code. Both are great tools, though.

pepe wrote:

I want to start diving into BDD. I have never used TDD before and am not sure if I should start by learning RSpec and then jump to Cucumber or just go straight to using Cucumber.

Use both. RSpec is for unit tests, while Cucumber tests user-facing features (and can use steps written in RSpec). Learn RSpec first, but after getting the basics, learn Cucumber alongside it.

I have been reading on the internet about both and it seems to me that Cucumber could be a 'replacement' for RSpec. Am I right or should be one used for certain things and the other one for others?

Cucumber is absolutely not a replacement for RSpec. The two are complementary. Cucumber is a replacement for integration tests.

Thanks in advance.

Pepe

Best,

Thanks for the answers.

How long do you think it could take for a non initiated person like myself to get used to using BDD and learning RSpec and cucumber?

Thanks again.

Sorry, one more thing. What could be the best sources of information to learn how to use both tools? I learn much better with examples.

I have searched for the RSpec book, which for what I've read has both subjects in it, but it seems it's not yet available.

Thank you.

Sorry, one more thing. What could be the best sources of information

to learn how to use both tools? I learn much better with examples.

I have searched for the RSpec book, which for what I’ve read has both

subjects in it, but it seems it’s not yet available.

Thank you.

Pepe, I would recommend getting the PDF now because this book is due to

release in February. Other than that, you might want to try the following web

sites:

http://rspec.info/

http://cukes.info/

Lastly, there are many screencasts on the subject which can be easily found using

Google.

Good luck,

-Conrad

There are the bddcasts: www.bddcasts.com They do cost money, but they're worth it, so is the rspec book.

A word of advice: Learning RoR at the same time with Cucumber and RSpec will require you to fight a very steep learning curve. Very often you will neither know how to test something nor how to implement it. You do get a lot of insight into Rails and you'll learn what every LOC does. But it's also over with easy copy&pasting code, taking chunks from tutorials and all that. This requires for you to really know what you're doing or if you don't - you will have to learn.

The quick and dirty solution with BDD doesn't exist. It can be worth it, but it takes long.

I would suggest to get your Rails knowledge on a solid foundation first. "Solid" means stuff you really know and can do - not a collage of railscasts. After that BDD won't be that hard.

Hope that helps Ray

Ray K. wrote:

There are the bddcasts: www.bddcasts.com They do cost money, but they're worth it, so is the rspec book.

A word of advice: Learning RoR at the same time with Cucumber and RSpec will require you to fight a very steep learning curve. Very often you will neither know how to test something nor how to implement it. You do get a lot of insight into Rails and you'll learn what every LOC does. But it's also over with easy copy&pasting code, taking chunks from tutorials and all that. This requires for you to really know what you're doing or if you don't - you will have to learn.

The quick and dirty solution with BDD doesn't exist. It can be worth it, but it takes long.

I would suggest to get your Rails knowledge on a solid foundation first. "Solid" means stuff you really know and can do - not a collage of railscasts. After that BDD won't be that hard.

Hope that helps Ray

My approach has been:

- use the Agile web development with Rails book to get my 'rails beginner badge' - used forums such as these and the excellent stuff over on railscasts.com to help bed the knowledge in a bit - Developed my first basic app and deployed it on Heroku

With the basics in place I've now picked up the RSpec book and it seems to be at the right time. I have a couple of rails apps in the pipeline and would like to approach them using BDD and with the bsic rails knowledge i have the book is making sense. It helps that I have alot of experience in software testing and i can comfortably see where the boundary between rspec and cucumber exists (and also where other tools such as selenium and webrat pick up as well).

Just to echo the previous poster though - i'd recommend getting the rails basics down first and perhaps develop a small application of your own as well.

pepe wrote:

Sorry, one more thing. What could be the best sources of information to learn how to use both tools? I learn much better with examples.

I have searched for the RSpec book, which for what I've read has both subjects in it, but it seems it's not yet available.

I learned both Cucumber and RSpec from the official websites.

Thank you.

Best,

Ray K. wrote:

There are the bddcasts: www.bddcasts.com They do cost money, but they're worth it, so is the rspec book.

A word of advice: Learning RoR at the same time with Cucumber and RSpec will require you to fight a very steep learning curve. Very often you will neither know how to test something nor how to implement it. You do get a lot of insight into Rails and you'll learn what every LOC does. But it's also over with easy copy&pasting code, taking chunks from tutorials and all that. This requires for you to really know what you're doing or if you don't - you will have to learn.

The quick and dirty solution with BDD doesn't exist. It can be worth it, but it takes long.

That's absolutely false. I learned Rails and RSpec at the same time (Cucumber didn't exist yet). It was no problem.

I would suggest to get your Rails knowledge on a solid foundation first. "Solid" means stuff you really know and can do - not a collage of railscasts. After that BDD won't be that hard.

No, no, no! Then you'll be writing untested code, which is worse. Definitely don't go for the collage of Railscasts, but don't hold off on learning proper testing either. It's an essential part of programming in the 21st century.

Hope that helps Ray

Best,

Learn it in parallel. Any resource will work just fine, you will learn the basics easily.

Well, unfortunately untested code is part of reality. Although I have tried to be good and test all I could I have not followed a methodology or tool to get things done right the first time and be more efficient at it and I am sure there are parts of my code that I missed, reason why I am so interested in BDD.

Ruby and Rails should not be a major problem. Although I am no expert I can push my way through getting scratched by thorns and everything else in the process. :wink: Although at times painful, I have learned a lot so far.

Thank you all very much for your ideas and the will to share your knowledge.

Pepe

Quoting pepe <Pepe@BetterRPG.com>: [snip]

Ruby and Rails should not be a major problem. Although I am no expert I can push my way through getting scratched by thorns and everything else in the process. :wink: Although at times painful, I have learned a lot so far.

Nice metaphor. I empathize and sympathize.

Jeffrey

Thanks Jeffrey. :slight_smile: