Sha256: 89a5098291dd6f887b656075aa08cd06478d6baf26b3465471825d34872b1ec1

Contents?: true

Size: 981 Bytes

Versions: 22

Compression:

Stored size: 981 Bytes

Contents

require 'test_helper'

class CSVSerializerTest < ActiveSupport::TestCase
  test "blank values are dumped as nil" do
    assert_dumped nil, ''
    assert_dumped nil, '  '
    assert_dumped nil, nil
    assert_dumped nil, []
  end

  test "blank values are loaded as an empty array" do
    assert_loaded [], ''
    assert_loaded [], '  '
    assert_loaded [], nil
  end

  test "load split the words by comma" do
    assert_loaded %w(foo bar), 'foo,bar'
  end

  test "dump join the words with a comma" do
    assert_dumped 'foo,bar', %w(foo bar)
  end

  private

  def assert_dumped(expected, object)
    message = "Expected CSVSerializer.dump(#{object.inspect}) to eq #{expected.inspect}"
    assert_equal(expected, Shipit::CSVSerializer.dump(object), message)
  end

  def assert_loaded(expected, payload)
    message = "Expected CSVSerializer.load(#{payload.inspect}) to eq #{expected.inspect}"
    assert_equal(expected, Shipit::CSVSerializer.load(payload), message)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
shipit-engine-0.5.2 test/unit/csv_serializer_test.rb
shipit-engine-0.5.1 test/unit/csv_serializer_test.rb
shipit-engine-0.5.0 test/unit/csv_serializer_test.rb
shipit-engine-0.4.10 test/unit/csv_serializer_test.rb
shipit-engine-0.4.9 test/unit/csv_serializer_test.rb
shipit-engine-0.4.8 test/unit/csv_serializer_test.rb
shipit-engine-0.4.7 test/unit/csv_serializer_test.rb
shipit-engine-0.4.6 test/unit/csv_serializer_test.rb
shipit-engine-0.4.5 test/unit/csv_serializer_test.rb
shipit-engine-0.4.4 test/unit/csv_serializer_test.rb
shipit-engine-0.4.3 test/unit/csv_serializer_test.rb
shipit-engine-0.4.2 test/unit/csv_serializer_test.rb
shipit-engine-0.4.1 test/unit/csv_serializer_test.rb
shipit-engine-0.4.0 test/unit/csv_serializer_test.rb
shipit-engine-0.3.1 test/unit/csv_serializer_test.rb
shipit-engine-0.3.0 test/unit/csv_serializer_test.rb
shipit-engine-0.2.3 test/unit/csv_serializer_test.rb
shipit-engine-0.2.2 test/unit/csv_serializer_test.rb
shipit-engine-0.2.1 test/unit/csv_serializer_test.rb
shipit-engine-0.2.0 test/unit/csv_serializer_test.rb