Sha256: 0ac12f27c553cdfed21a3de29fae10cb8d688cfc5654a8cb254cc74ce56a5deb

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require File.join(File.dirname(__FILE__), "test_helper")
require 'lib/eeml/csv_parser_v2.rb'
class TestCsvParserV2 < Test::Unit::TestCase

  test "should raise exception if line breaks have dodgy characters" do
    csv = "20,305\\n30,1305"
    exception = assert_raises CsvEncodingError do
      CsvParserV2.make_environment_from_csv(csv)
    end
    assert_equal "CSV is invalid. Double check you are properly encoding line breaks.", exception.message
  end

  test "should raise exception if too many fields" do
    csv = "20,54,305\n30,1305"
    exception = assert_raises CsvEncodingError do
      CsvParserV2.make_environment_from_csv(csv)
    end
    assert_equal "CSV is invalid. Incorrect number of fields.", exception.message
  end

  test "should parse and return Environment object with datastreams" do
    csv = "20,10\n5,6"
    environment = CsvParserV2.make_environment_from_csv(csv)
    assert_equal 2, environment.datastreams.length
    assert_equal "20", environment.datastreams.first.identifier
    assert_equal "10", environment.datastreams.first.value

    assert_equal "5", environment.datastreams.last.identifier
    assert_equal "6", environment.datastreams.last.value
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eeml-0.0.25 test/test_csv_parser_v2.rb
eeml-0.0.24 test/test_csv_parser_v2.rb
eeml-0.0.23 test/test_csv_parser_v2.rb
eeml-0.0.22 test/test_csv_parser_v2.rb