Sha256: a16c03828d8f3ba398017d988759fc877ecf659d61500ab055bd6ec1cc48ac76

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

require 'helper'

describe Adapter::Defaults do
  let(:mod) do
    Module.new.tap do |m|
      m.extend(Adapter::Defaults)
    end
  end

  describe "#key_for" do
    it "returns value for string" do
      mod.key_for('foo').should == 'foo'
    end

    it "returns string for symbol" do
      mod.key_for(:foo).should == 'foo'
    end

    it "marshals anything not a string or symbol" do
      mod.key_for({'testing' => 'this'}).should == %Q(\004\b{\006\"\ftesting\"\tthis)
    end
  end

  describe "#encode" do
    it "marshals value" do
      mod.encode(nil).should == "\004\b0"
      mod.encode({'testing' => 'this'}).should == %Q(\004\b{\006\"\ftesting\"\tthis)
    end
  end

  describe "#decode" do
    it "returns nil if nil" do
      mod.decode(nil).should be_nil
    end

    it "returns marshal load if not nil" do
      mod.decode(%Q(\004\b{\006\"\ftesting\"\tthis)).should == {'testing' => 'this'}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adapter-0.5.2 spec/adapter/defaults_spec.rb
adapter-0.5.1 spec/adapter/defaults_spec.rb
adapter-0.5 spec/adapter/defaults_spec.rb