Sha256: 56d83836513a15e789e2be9e2a4c8d34325821b24d450eec5fff389cc6fc31b2

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path('../abstract_unit', __FILE__)

class CompositeArraysTest < ActiveSupport::TestCase

  def test_new_primary_keys
    keys = CompositePrimaryKeys::CompositeKeys.new
    assert_not_nil keys
    assert_equal '', keys.to_s
    assert_equal '', "#{keys}"
  end

  def test_initialize_primary_keys
    keys = CompositePrimaryKeys::CompositeKeys.new([1,2,3])
    assert_not_nil keys
    assert_equal '1,2,3', keys.to_s
    assert_equal '1,2,3', "#{keys}"
  end

  def test_to_composite_keys
    keys = [1,2,3].to_composite_keys
    assert_equal CompositePrimaryKeys::CompositeKeys, keys.class
    assert_equal '1,2,3', keys.to_s
  end

  def test_parse
    assert_equal ['1', '2'], CompositePrimaryKeys::CompositeKeys.parse('1,2')
    assert_equal ['The USA', '^Washington, D.C.'],
                 CompositePrimaryKeys::CompositeKeys.parse('The USA,^5EWashington^2C D.C.')
    assert_equal ['The USA', '^Washington, D.C.'],
                 CompositePrimaryKeys::CompositeKeys.parse(['The USA', '^Washington, D.C.'])
  end

  def test_to_s
    assert_equal '1,2', CompositePrimaryKeys::CompositeKeys.new([1, 2]).to_s
    assert_equal 'The USA,^5EWashington^2C D.C.',
                 CompositePrimaryKeys::CompositeKeys.new(['The USA', '^Washington, D.C.']).to_s
  end

  def test_to_param
    assert_equal '1,2', CompositePrimaryKeys::CompositeKeys.new([1, 2]).to_param
    assert_equal 'The USA,^5EWashington^2C D.C.',
                 CompositePrimaryKeys::CompositeKeys.new(['The USA', '^Washington, D.C.']).to_param
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
composite_primary_keys-14.0.7 test/test_composite_arrays.rb
composite_primary_keys-14.0.6 test/test_composite_arrays.rb
composite_primary_keys-14.0.5 test/test_composite_arrays.rb