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.