Sha256: 631af79d86dae6ba340e0d6fcb7609f831e3498aa40f53ca34fc4b658f59ce37
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'ostruct' require 'test/unit' require File.join(File.dirname(__FILE__),"..","lib","refcode.rb") class RefcodeEncoderTest < Test::Unit::TestCase SECRET = "686cb0461769ebed556f56bc88c956bfdf786646ab1920f58201723c557ccbaeb57112fd53302c06475e6e19a176ba617ee284b091d375858cb259e8578c620f" SALT = "dcc74de5efdab0d80b5d763f8a63bef3d37c7453ee45446fbbccd26648af8ca6a112576dafbf5475f3cd7b968703cc9e0682ee45b8b622045cec287908f536e8" def test_encoder_against_hash test_hash = { :channel => 'email', :record_id => 49203, :action => 'forward' } assert_equal test_hash, encode_and_decode(test_hash) end def test_encoder_against_string test_string = "secret referral data" assert_equal test_string, encode_and_decode(test_string) end def test_encoder_against_int assert_equal 4857, encode_and_decode(4857) end def test_encoder_against_open_struct test_struct = OpenStruct.new({:test => 42}) assert_equal test_struct, encode_and_decode(test_struct) end private def encoder @encoder ||= Refcode::Encoder.new do |e| e.secret = SECRET e.salt = SALT end end def encode_and_decode val encoder.decode(encoder.encode(val)) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
refcode-0.1.2 | test/refcode_encoder_test.rb |
refcode-0.1.1 | test/refcode_encoder_test.rb |