Sha256: 6246a23052086a775ada29dae9ca6f530c97f895b5f01b627c6463e18d571291
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require "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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
url_store-0.3.4 | spec/url_store/compact_encoder_spec.rb |