Sha256: 428925667ed82a6b6e4ccb9ed1d25783aa5b33cefe64a671d80655201e082159
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
require 'helper' describe RemoteTable do describe ":parser option" do it "takes a parser object that responds to #parse(row) and returns an array of rows" do class GradeRangeParser def parse(row) row['range'].split('-').map do |subrange| virtual_row = row.dup virtual_row.delete 'range' virtual_row['grade'] = subrange virtual_row end end end t = RemoteTable.new "file://#{File.expand_path('../data/ranges.csv', __FILE__)}", parser: GradeRangeParser.new t[0].must_equal 'description' => 'great', 'grade' => 'A' t[1].must_equal 'description' => 'great', 'grade' => 'B' t[2].must_equal 'description' => 'ok', 'grade' => 'C' t[3].must_equal 'description' => 'bad', 'grade' => 'D' t[4].must_equal 'description' => 'bad', 'grade' => 'F' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
remote_table-3.0.0.beta | test/test_parser.rb |
remote_table-3.0.0.alpha | test/test_parser.rb |