[rspec-users] calling multiline steps from other steps

Ben Mabey ben at benmabey.com
Thu Dec 4 22:33:19 EST 2008


Pau Cor wrote:
> What is the syntax for calling multiline steps from other steps? I'd
> like to do something like this:
>
> Given /^I have filled in the form$/ do |details|
>   details.hashes.each |pair|
>     When "I fill in #{pair['field']} with #{pair['value']}"
>   end
> end
>
>   
Yes, you can do this.
> Given /^(.*) has filled in the form$/ do |user, details|
>   Given "I am logged in and #{user}"
>   Given "I have filled in the form", details
>   When "I log out"
> end
> My feature file would have something like this:
>
>   Given Joe has filled in the form:
>     | field | value |
>     | x     | 1     |
>     | y     | 2     |
>
>
> I'd also like to do something like this:
>
> Given /^Everything is filled in$/ do
>   Given "Joe has filled in the form:
>     | field | value |
>     | x     | 1     |
>     | y     | 2     |"
> end
>
>   
I'm not sure if it works with step tables, so you will just have to 
experiment and see.  Same thing for the multi-line strings.. I'm not 
sure but that seems more possible that the step table.
> How can I do this? Also, how does it work for multi line strings (""")?
>
> Thanks!
> Paul
>
> P.S. Those are contrived examples.
>   



More information about the rspec-users mailing list