Module: Test::Unit::Data::ClassMethods

Defined in:
lib/test/unit/data.rb

Defined Under Namespace

Classes: CSVDataLoader

Instance Method Summary (collapse)

Instance Method Details

- (Object) data(*arguments, &block)

TODO: WRITE ME.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/test/unit/data.rb', line 12

def data(*arguments, &block)
  n_arguments = arguments.size
  case n_arguments
  when 0
    data_set = block
  when 1
    data_set = arguments[0]
  when 2
    data_set = {arguments[0] => arguments[1]}
  else
    message = "wrong number arguments(#{n_arguments} for 1..2)"
    raise ArgumentError, message
  end
  current_data = current_attribute(:data)[:value] || []
  attribute(:data, current_data + [data_set])
end

- (Object) load_data(file_name)

TODO: WRITE ME.



30
31
32
33
34
35
36
37
38
# File 'lib/test/unit/data.rb', line 30

def load_data(file_name)
  case file_name
  when /\.csv/i
    loader = CSVDataLoader.new(self)
    loader.load(file_name)
  else
    raise ArgumentError, "unsupported file format: <#{file_name}>"
  end
end