Parent

Methods

Files

Class/Module Index [+]

Quicksearch

Test::Unit::Data::ClassMethods::CSVDataLoader

Public Class Methods

new(test_case) click to toggle source
# File lib/test/unit/data.rb, line 41
def initialize(test_case)
  @test_case = test_case
end

Public Instance Methods

load(file_name) click to toggle source
# File lib/test/unit/data.rb, line 45
def load(file_name)
  require 'csv'
  header = nil
  CSV.foreach(file_name) do |row|
    if header.nil?
      header = row
      next
    end
    label = nil
    data = {}
    header.each_with_index do |key, i|
      if key == "label"
        label = row[i]
      else
        data[key] = normalize_value(row[i])
      end
    end
    @test_case.data(label, data)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.