Sha256: c13cfabf37d5cf42b7dc5231f5c9a107c00ae29bb4844e9ec9edbfd143707873

Contents?: true

Size: 1.71 KB

Versions: 7

Compression:

Stored size: 1.71 KB

Contents

require_relative '../helper'

class TestSkeinSupport < Test::Unit::TestCase
  def test_symbolize_keys_simple_hash
    hash = {
      'test' => 'test_value',
      true => 'true_value',
      2 => 'two'
    }

    expected = {
      test: 'test_value',
      true: 'true_value',
      '2': 'two'
    }

    assert_equal(expected, Skein::Support.symbolize_keys(hash))
  end

  def test_symbolize_keys_on_array
    array = [
      {
        'test' => :value,
        'nested' => {
          'hash' => true
        }
      },
      {
        'second' => :hash
      }
    ]

    expected = [
      {
        test: :value,
        nested: {
          hash: true
        }
      },
      {
        second: :hash
      }
    ]

    assert_equal(expected, Skein::Support.symbolize_keys(array))
  end

  def test_symbolize_keys_on_non_hashes
    assert_mapping(
      1 => 1,
      true => true,
      nil => nil,
      'test' => 'test',
      :symbol => :symbol
    ) do |value|
      Skein::Support.symbolize_keys(value)
    end
  end

  def test_hostname
    hostname = Skein::Support.hostname

    assert_equal(String, hostname.class)
    assert(hostname.length > 0)
  end

  def test_process_name
    process_name = Skein::Support.process_name

    assert(process_name)

    assert(%w[ test_skein_support rake_test_loader ].include?(process_name))
  end

  def test_pid
    process_id = Skein::Support.process_id

    assert(process_id)
    assert(process_id.is_a?(Integer))
  end

  def test_arrayify
    assert_mapping(
      [ :test ] => [ :test ],
      :test => [ :test ],
      true => [ true ],
      0 => [ 0 ],
      [ 0 ] => [ 0 ],
      [ nil ] => [ nil ],
      nil => nil
    ) do |value|
      Skein::Support.arrayify(value)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skein-0.8.1 test/unit/test_skein_support.rb
skein-0.3.7 test/unit/test_skein_support.rb
skein-0.3.6 test/unit/test_skein_support.rb
skein-0.3.5 test/unit/test_skein_support.rb
skein-0.3.2 test/unit/test_skein_support.rb
skein-0.3.1 test/unit/test_skein_support.rb
skein-0.3.0 test/unit/test_skein_support.rb