[rspec-users] calling multiline steps from other steps

Pau Cor lists at ruby-forum.com
Thu Dec 4 21:36:06 EST 2008


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

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


How can I do this? Also, how does it work for multi line strings (""")?

Thanks!
Paul

P.S. Those are contrived examples.
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list