[rspec-users] testing controllers using cucumber

Matt Patterson matt-lists at reprocessed.org
Fri Jan 29 07:16:20 EST 2010

On 29 Jan 2010, at 11:53, Amit Kulkarni wrote:

> Hello,
> Is there any way to test controllers using cucumber.
> I was doing it with rspec but since cucumber's description is good how
> can i proceed testing it with cucumber?

Hi Amit. There's a Cucumber specific mailing list at http://groups.google.com/group/cukes?pli=1, which is a better place to ask Cucumbetr questions.

With Cucumber, you don't tend to test controllers directly, instead you're testing the whole app, much like Rails' own Integration Tests.

> For e.g.
> I have a scenario of user creation like
> Feature: User Scenarios
>  Scenario: Successfull creation of user
>    Given a new user
>    When the user fill all the mandatory details
>    Then that user should get created
>    And success message should get displayed and email should be sent
> for activation

So, your example might be implemented like this:

Given /^I'm on the new user page$/ do
  visit new_user_path

When /^I fill all the mandatory details$/ do
  fill_in("name", :with =>"Joe")

Then /^that user should get created$/ do
  User.find_by_name("Joe").should_not be_nil

> In this how i need to call the users controller and in that create
> method.
> Also i searched in the net but didn't found any examples for cucumber
> testing controllers.

There are lots of examples on the Cucumber site http://cukes.info/



  Matt Patterson | Design & Code
  <matt at reprocessed org> | http://www.reprocessed.org/

More information about the rspec-users mailing list