Skip to content

Instantly share code, notes, and snippets.

@heptat
Created March 25, 2011 04:12
Show Gist options
  • Save heptat/886352 to your computer and use it in GitHub Desktop.
Save heptat/886352 to your computer and use it in GitHub Desktop.
# assume the field to search on is "name"
Given /^the ([^\s]+) "([^"]+)" belongs to(?: the) ([^\s]+) "([^"]+)"$/ do |model, value, parent_model, parent_value|
Given "the #{model} with the name \"#{value}\" belongs to the #{parent_model} with the name \"#{parent_value}\""
end
Given /^the ([^\s]+) with the ([^\s]+) "([^"]+)" belongs to(?: the) ([^\s]+) with the ([^\s]+) "([^"]+)"$/ do |model, field, value, parent_model, parent_field, parent_value|
# get the id for the first thing
# get the id for the second thing
model_id = get_id(model, field, value)
parent_id = get_id(parent_model, parent_field, parent_value)
Given "the following #{parent_model} #{model} joins exist:", table(%{
| #{parent_model}_id | #{model}_id |
| #{parent_id} | #{model_id} |
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment