Rspec or Cucumber?


Cucumber is a tool that executes plain-text functional descriptions as automated tests.

Cucumber is intended to be used for acceptance tests. Cucumber steps include checks for
rendering and redirection and also view content — in other words,
full coverage is still maintained.

Cucumber functionality

1) Define feature scenario in cucumber for what my end goal is for the functionality
2) Start implementing each step of the feature scenario
3) For each part of functionality required that is in a model, BDD that with rspec
4) repeat until functionality is complete

That way you have Integration testing covered for an end to end request in your application, and each part of your model can be built and tested in isolation as well using rspec or test unit.

The only downside I’ve seen with cucumber so far is, since it’s full
stack, you need to get your data setup correctly.  For my project the
data relationship are complex so I’ve had to resort to some heavy handed
data manipulation in the setup (e.g. Model.delete_all).


RSpec is a behavior driven development (BDD) framework for the Ruby programming language, inspired by JBehave.

Difference between Rspec or Cucumber?

Cucumber to drive the main features and RSpec to flush out
more difficult cases.  Just today I got into the cycle of:

Cucumber is intended to be used for acceptance tests, and rspec for unit tests.

You should be using both. Well either that or cucumber and test unit.

Cucumber takes care of your integration/acceptance testing, and rspec/test unit should take care of your model unit tests. A typical workflow for me with this is,

2 thoughts on “Rspec or Cucumber?

  1. Radhika says:

    Excellent!!!..I was struggling to know the basic implementation of RSpec and Cucumber. You have explained very well..Thanks for the post!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s