Sha256: 18c986a22f72e9b29a22eaa98597bae4e31847ca08827bcd6d7c1c25823a9b9b

Contents?: true

Size: 587 Bytes

Versions: 2

Compression:

Stored size: 587 Bytes

Contents

require "spec_helper"

describe Mashed::StringyHash do
  let(:hash) {{ a: 1, b: 2, c: { three: 3 }}}

  describe "#stringify" do
    it { expect(hash.stringify).to eq("a" => 1, "b" => 2, "c" => { "three" => 3 }) }
  end

  describe "get and set" do
    let(:s) { hash.stringify }
    before { s[:a] = "A" }
    it { expect(s[:a]).to eq("A") }
    it { expect(s["a"]).to eq("A") }
  end

  describe "calls to_s on objects" do
    let(:s) { hash.stringify }
    let(:klass) {
      Class.new do
        def to_s; "a"; end
      end
    }
    it { expect(s[klass.new]).to eq(1) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mashed-0.9.1 spec/mashed/stringy_hash_spec.rb
mashed-0.9.0 spec/mashed/stringy_hash_spec.rb