Skip to content

Instantly share code, notes, and snippets.

@josephholsten
Created February 20, 2010 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephholsten/309794 to your computer and use it in GitHub Desktop.
Save josephholsten/309794 to your computer and use it in GitHub Desktop.
def pretty_factory_name name
name.to_s.gsub '_', ' '
end
Factory.factories.each do |name, factory|
Given( /^an? #{pretty_factory_name name} exists$/ ) do
Factory(name)
end
Given( /^an? #{pretty_factory_name name} exists with an? (.*) of "([^"]*)"$/ ) do |attr, value|
Factory(name, attr.gsub(' ', '_') => value)
end
Given( /^the following #{pretty_factory_name name} records?$/ ) do |table|
table.hashes.each do |hash|
Factory(name, hash)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment