test/URLcrypt_test.rb in urlcrypt-0.1.0 vs test/URLcrypt_test.rb in urlcrypt-0.1.1

- old
+ new

@@ -1,10 +1,18 @@ # encoding: utf-8 +require 'bundler' +Bundler.require(:default, :test) + +require 'coveralls' +Coveralls.wear! + require 'test/unit' -require 'URLcrypt' class TestURLcrypt < Test::Unit::TestCase + + require 'URLcrypt' + def assert_bytes_equal(string1, string2) bytes1 = string1.bytes.to_a.join(':') bytes2 = string2.bytes.to_a.join(':') assert_equal(bytes1, bytes2) end @@ -54,6 +62,12 @@ original = "hello world!" encrypted = URLcrypt::encrypt(original) assert_equal(URLcrypt::decrypt(encrypted), original) end + def test_decrypt_error + error = assert_raises(URLcrypt::DecryptError) do + ::URLcrypt::decrypt("just some plaintext") + end + assert_equal error.message, "not a valid string to decrypt" + end end