Skip to content

Instantly share code, notes, and snippets.

@ohammersmith
Created April 24, 2009 03:35
Show Gist options
  • Save ohammersmith/100913 to your computer and use it in GitHub Desktop.
Save ohammersmith/100913 to your computer and use it in GitHub Desktop.
Given /^There (?:is|are) (\d+|a) (.*?)(.*?)(?: with "(.*?)" for (.*?))?$/ do |count, model, factory_suffix, value, attribute|
count = 1 if count == "a"
factory_name = model.singularize << factory_suffix.gsub(" ", "_")
if attribute and value
count.to_i.times { Factory(factory_name.to_sym, attribute.to_sym => value) }
else
count.to_i.times { Factory(factory_name.to_sym) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment