Cucumber and rspec, do cucumber step definitions use rspec?

I’m a bit confused as to how cucumber and rspec integrate (if they d at
all?).

You write a cucumber feature, and step definitions.
Now in the step definitions, do you write rspec in the step definitions
or
do they somehow link to the spec’s written elsewhere?

On 9 May 2011 15:00, S Ahmed [email protected] wrote:

I’m a bit confused as to how cucumber and rspec integrate (if they d at
all?).

You write a cucumber feature, and step definitions.
Now in the step definitions, do you write rspec in the step definitions or
do they somehow link to the spec’s written elsewhere?

Cucumber and rspec are different tools. Cucumber is aimed at a higher level
(functional) whilst rspec is aimed at the unit level. So Cucumber
features
specify your applications behaviour, whilst rspec specifies your objects
(and/or classes) behaviour.

The best place to see how they work in tandem is the RSpec Book.

All best

Andrew

Andrew, I’ve actually read allot of the book (but admittedly I brushed
over
the cucumber sections), but I was confused at this point.

I understand the outside in development, etc.

What I was confused at was if the two technologies actually integrate at
some point.

i.e. if you run cucumber, will it go and run spec’s for you also?

Correct me if I am wrong, but the cucumber step definitions do indeed
use
webrat to hit the pages and verify things in the view pages correct?

On 9 May 2011, at 16:00, S Ahmed wrote:

I’m a bit confused as to how cucumber and rspec integrate (if they d at all?).

You write a cucumber feature, and step definitions.
Now in the step definitions, do you write rspec in the step definitions or do
they somehow link to the spec’s written elsewhere?

You write Ruby code in the step definitions. Because Cucumber is a
testing tool, you often want to make assertions in that Ruby code about
how the system you’re testing is behaving. RSpec gives you assertions,
so you can use RSpec’s assertions in your step definitions. You can also
use Ruby’s own built-in assertions from the Test::Unit::Assertions
namespace.

cheers,
Matt


Freelance programmer & coach
Founder, http://relishapp.com
+44(0)7974430184 | http://twitter.com/mattwynne

On May 10, 2011, at 11:50 AM, aslak hellesoy wrote:

On Mon, May 9, 2011 at 3:00 PM, S Ahmed [email protected] wrote:
I’m a bit confused as to how cucumber and rspec integrate (if they d at all?).

RSpec is two things:
a) A runner (command line program)
b) An assertion library (should, should_not, be_nil and friends)

c) mocking/stubbing

Cucumber doesn’t use a) at all.
If you want, you can use b) in your step definitions. If you don’t, Cucumber
won’t use RSpec at all.

Same for stubs.

Cheers,
David

On Mon, May 9, 2011 at 4:12 PM, S Ahmed [email protected] wrote:

Nope

Correct me if I am wrong, but the cucumber step definitions do indeed use
webrat to hit the pages and verify things in the view pages correct?

Cucumber-Rails generates some step definitions for you in
features/step_definitions/web_steps.rb that:

  • Use Webrat or Capybara, depending on the command line options you pass
    to
    the cucumber:install generator
  • We recommend you delete those stepdefs and write your own, based on
    the
    Capybara API.
  • Cucumber-Rails 0.5.0 will not support Webrat at all, only Capybara

Aslak

On Mon, May 9, 2011 at 3:00 PM, S Ahmed [email protected] wrote:

I’m a bit confused as to how cucumber and rspec integrate (if they d at
all?).

RSpec is two things:
a) A runner (command line program)
b) An assertion library (should, should_not, be_nil and friens)

Cucumber doesn’t use a) at all.
If you want, you can use b) in your step definitions. If you don’t,
Cucumber
won’t use RSpec at all.

HTH,
Aslak

You write a cucumber feature, and step definitions.