Class DynamicReports::Test::ArrayRecords

  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 7
      def self.generate(report, *options)
        records = []
        options = options.shift || {}
        (0..(options[:count].to_i)).each do |index|
          hash = {}
          report.columns.each do |column|
            hash[column.to_s] = 
            case column.to_s
            when /_at$/
              (DateTime.now-100)+index
            when /_on$/
              (Date.today-100)+index
            when /_id$/,/_count$/
              rand(10000)
            else
              column
            end
          end
          records << hash
        end
        records
      end