Class DynamicReports::Test::ObjectRecords

  1. test/test_helper.rb
Parent: Object

Methods

public class

  1. generate

Public class methods

generate (report,*options)
[show source]
# File test/test_helper.rb, line 32
      def self.generate(report,*options)
        records = []
        options = options.shift || {}
        (0..(options[:count].to_i)).each do |index|
          object = OpenStruct.new(report.columns)
          report.columns.each do |column|
            value = case column.to_s
            when /_at$/
              (DateTime.now-100)+index
            when /_on$/
              (Date.today-100)+index
            when /_id$/,/_count$/
              rand(10000)
            else
              column
            end
    
            object.send(column.to_sym, value)
    
            records << object
          end
          records
        end
      end