Sha256: bbf5146eddb15e90c714903038ff27b95c54ce5b39c04979a1013c19ffb2e36b

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

# encoding: utf-8
require 'test_helper'

class TestURLcrypt < TestClass
  def test_empty_string
    assert_encode_and_decode('', '')
  end

  def test_encode
    assert_encode_and_decode(
      '111gc86f4nxw5zj1b3qmhpb14n5h25l4m7111',
      "\0\0awesome \n ΓΌ string\0\0")
  end

  def test_invalid_encoding
    assert_decoding('ZZZZZ', '')
  end

  def test_arbitrary_byte_strings
    0.step(1500,17) do |n|
      original = (0..n).map{rand(256).chr}.join
      encoded = URLcrypt::encode(original)
      assert_decoding(encoded, original)
    end
  end

  def test_key_deprecation
    URLcrypt.key = 'aaaa'
    assert_equal "\xAA\xAA", ENV.fetch('urlcrypt_key')
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
urlcrypt-0.2.0 test/URLcrypt_test.rb