Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
Rorem ===== Rorem is a random data generator that automatically fill Ruby classes with Random data, here's how: class Car include Rorem::Model attr_accessor :brand, :seats, :owner_name, :owner_age, :special_car end Car.factory do |car| # all brands are equality likely car.brand = random(%w(BMW Mercedes Volvo Jaguar)) # assign probabilities to each value car.seats = random([2, 4], :distribution => [0.2, 0.8]) # use a normal distribution to describe probabilities car.owner_age = random(18..70, :distribution => normal(40, 15)) # generate a name from rorem's database of names car.owner_name = random(:name # a deterministic value can be set car.special_car false end c = Car.new c.fill c.brand #=> 'BMW' c.seats #=> 4 c.owner_age #=> 27 c.owner_name #=> 'Allan Hernandez' c.special_car #=> false another (more complex) example class Employee include Rorem::Model attr_accessor :first_name, :last_name, :email, :employee_nr, :empolyee_id, :address, :city, :country end Employee.factory do c.employee_nr = sequence(:employee_nr, :start => 1) person = random(:person, :unique => true) location = random(:location) c.first_name = person.first_name c.last_name = person.last_name c.email = person.email c.address = location.address c.city = location.city c.country = location.country c.employee_id = c.first_name[1..3] + c.last_name[1..4] + c.employee_nr.to_s end