you could use tables
....feature:
...
Given the site has the following pages
|page title|
| title 1 |
| title 2 |
| title 3 |
....
...steps.rb:
...
Given /^the site has the following pages$/ do | pages |
pages.each |page_title|
Page.create :title => page_title unless Page.find_by_title
(page_title)
end
end
...
On 7 Dez., 10:52, Gintautas Šimkus
<dihita...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello,
>
> I have this cucumber step definition:
>
> Given /^the site has pages "(.+)" and "(.+)"$/ do |
page_1, page_2 |
> Page.create :title => page_1 if Page.find_by_title(page_1).nil?
> Page.create :title => page_2 if Page.find_by_title(page_2).nil?
> end
>
> This works, but obviously I would like to DRY it up. I was thinking along
> the lines.
>
> Given /^the site has pages "(.+)" and "(.+)"$/ do |
*args |
> args.each { |page| Page.create :title => page if
> Page.find_by_title(page).nil? }
> end
>
> The code is not syntactically correct that is what my question is about:
how
> to implement this concept right?
>
> Thanks.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.