Sha256: 9cf2d38d3b945c69d2098f6afbfe730a714217744a17062fbaaf590d9efbe0db
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper' describe UrlStore::CompactEncoder do before do @encoder = UrlStore::CompactEncoder.new(:secret => 'asdasdsa') @data = {:x => 1, 'asdadadadas' => 'asdasdadawvxcxcxcvjs', 'dasdasdadsadad' => 'asdasdwxczvvcjjkdfjkdf'} end it "generates same code for same data" do @encoder.encode(@data).should == @encoder.encode(@data) end it "can decode / encode" do @encoder.decode(@encoder.encode(@data)).should == @data end it "generates shorter codes than pure base64" do hash_length = 40 @encoder.encode(@data).size.should < (Base64.encode64(Marshal.dump(@data)).size + hash_length) end it "can encode/decode with yaml" do @encoder = UrlStore::CompactEncoder.new(:secret => 'asdasdsa', :serializer => :yaml) @encoder.decode(@encoder.encode(@data)).should == @data end it "can hash with other hasher" do @encoder = UrlStore::CompactEncoder.new(:secret => 'asdasdsa', :hasher => 'MD5') @encoder.decode(@encoder.encode(@data)).should == @data end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
url_store-0.3.2 | spec/url_store/compact_encoder_spec.rb |
url_store-0.3.1 | spec/url_store/compact_encoder_spec.rb |
url_store-0.3.0 | spec/url_store/compact_encoder_spec.rb |