Skip to content

Instantly share code, notes, and snippets.

@stephenrichards
Created January 25, 2017 11:12
Show Gist options
  • Save stephenrichards/0a09d8d6beefc22c26ef8e25be82908e to your computer and use it in GitHub Desktop.
Save stephenrichards/0a09d8d6beefc22c26ef8e25be82908e to your computer and use it in GitHub Desktop.
Rakefile to create people with similar names for peoplefinder test
namespace :db do
task :pop => :environment do
include FactoryGirl::Syntax::Methods
Person.where('surname like ?', 'Me%').map(&:destroy)
names = [
%w{ Nicky Meadhurst },
%w{ Nicola Meadhurst },
%w{ Nicky Medhurst },
%w{ Nicola Medhurst },
%w{ Jane Meadhurst },
%w{ Jane Medhurst },
%w{ Nicky Meadows },
%w{ Nicola Meadows },
%w{ Nicky Meadows },
%w{ Sveinung Medaas },
%w{ Nikola Medaas }
]
names.each do |name|
person = build :person, given_name: name.first, surname: name.last, email: "#{name.first}.#{name.last}@digital.justice.gov.uk"
begin
person.save
rescue => err
puts err.message
ap person
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment