Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create samples
- #
- # Look for column belongs_to_users
- # This should contain values like creator:user1, approver:user2, and so
- # on, where 'creator' and 'approver' are belongs_to relationships like:
- #
- # belongs_to :creator, :class_name => "User", :foreign_key => "creator_id"
- #
- # and 'user1', and 'user2' are existing username values.
- #
- # This step finds those users by username and adds them to the hash,
- # deleting 'belongs_to_users' and leaving all other values in place.
- Given /^the following samples?$/ do |table|
- table.hashes.each { |hash|
- if (owners = hash.delete('belongs_to_users'))
- owners.split(/, ?/).each do |pair|
- kind,owner = pair.split(/:/)
- hash[kind] = User.find_by_username(owner)
- end
- end
- Factory(:sample,hash)
- }
- end
Add Comment
Please, Sign In to add comment