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
end

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

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

> 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/

HTH

Matt

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



_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to