Skip to content

Instantly share code, notes, and snippets.

@coshx
Created September 29, 2010 21:42
Show Gist options
  • Save coshx/603621 to your computer and use it in GitHub Desktop.
Save coshx/603621 to your computer and use it in GitHub Desktop.
Given /^an? (.+) exists with (?:an? )?(.+) (?:of )?\"([^\"]*)\"$/ do |model, field, value|
factory_name = model.gsub(' ', '_').to_sym
eval("@#{factory_name} = Factory.create(factory_name, field => value)")
end
@coshx
Copy link
Author

coshx commented Sep 29, 2010

When /^(?:|I )fill in "([^\"])" with the (?:the )?(.+)'s "([^\"]+)"(?: within "([^\"])")?$/ do |field, model, attrib, selector|
with_scope(selector) do
factory_name = model.gsub(' ', '_').to_sym
object = eval("@#{factory_name}")
fill_in(field, :with => object.send(attrib))
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment