Sha256: bd0c722e8d94c2fe7d1922d00de64e557a42d8c514e14ea71ed61eacd9b5f89b

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

class ColumnizerTest < MiniTest::Unit::TestCase

  def test_returns_empty_array
    assert_equal [[],[],[]], InColumns::Columnizer.new([]).columns(3)
  end

  def test_does_not_modify_input
    input = ['a', 'b', 'c']
    InColumns::Columnizer.new(input).columns(2)
    assert_equal ['a', 'b', 'c'], input
  end

  def test_distribute_exact_elements
    input = ['a', 'b']
    output = InColumns::Columnizer.new(input).columns(2)
    assert_equal [['a'], ['b']], output
  end

  def test_distribute_too_many_elements
    input = ['a', 'b', 'c', 'd', 'e']
    output = InColumns::Columnizer.new(input).columns(2)
    assert_equal [['a', 'c', 'e'], ['b', 'd']], output

    output = InColumns::Columnizer.new(input).columns(3)
    assert_equal [['a', 'd'], ['b', 'e'], ['c']], output
  end

  def test_distribute_too_few_elements
    input = ['a', 'b']
    output = InColumns::Columnizer.new(input).columns(3)
    assert_equal [['a'], ['b'], []], output
  end

end

class CoreExtensionTest < MiniTest::Unit::TestCase
  def test_does_not_extend_array_by_default
    assert ![].respond_to?(:in_columns)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
in_columns-0.0.1 test/in_columns/columnizer_test.rb