[rspec-users] 'And' step definition

David Chelimsky dchelimsky at gmail.com
Fri Dec 5 21:18:13 EST 2008


On Fri, Dec 5, 2008 at 8:16 PM, Mark Wilden <mark at mwilden.com> wrote:
> Can you have an And step in a feature? With this, I get a NoMethodError for
> 'And':
>
> Given /a company named (.+)/ do |name|
>   @company = Company.create!(:name => name)
> end
>
> And /a user named (.+)/ do |name|
>   @user = create_user name
> end
>
> I'm probably missing something really obvious.

And is something the grammar allows in scenarios, but it always maps
And (and But) to the last type of Given, When or Then. So what you
really have here is a Given step that you are invoking with an alias,
And, from the Scenario.

Cheers,
David

>
> ///ark
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list