Sha256: 09c88c43ce00c36ab163cd7a5778f2d930c683b3872c4640198c06cf3ec86c04

Contents?: true

Size: 869 Bytes

Versions: 22

Compression:

Stored size: 869 Bytes

Contents

require 'spec_helper'

describe Waistband::StringifiedHash do

  let(:hash) { Waistband::StringifiedHash.new }

  it "stringifies everything in a hash" do
    hash['name'] = :peter
    hash['description'] = {'full' => 'ok'}
    hash.stringify_all.should eql({'name' => 'peter', 'description' => "{\"full\"=>\"ok\"}"})
  end

  it "recurses" do
    hash['name'] = :peter
    hash['description'] = [1, 2, 3]
    hash.stringify_all.should eql({'name' => 'peter', 'description' => "[1, 2, 3]"})
  end

  it "creates a stringified array from a hash" do
    copy = Waistband::StringifiedHash.new_from({'name' => 'peter', 'description' => [1, 2, 3]})
    copy.should be_a Waistband::StringifiedHash
    copy['name'].should eql 'peter'
    copy['description'].should eql [1, 2, 3]
    copy.stringify_all.should eql({'name' => 'peter', 'description' => "[1, 2, 3]"})
  end

end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
waistband-0.8.5 spec/lib/stringified_hash_spec.rb
waistband-0.8.4 spec/lib/stringified_hash_spec.rb
waistband-0.8.3 spec/lib/stringified_hash_spec.rb
waistband-0.8.2 spec/lib/stringified_hash_spec.rb
waistband-0.8.1 spec/lib/stringified_hash_spec.rb
waistband-0.8.0 spec/lib/stringified_hash_spec.rb
waistband-0.7.4 spec/lib/stringified_hash_spec.rb
waistband-0.7.3 spec/lib/stringified_hash_spec.rb
waistband-0.7.1 spec/lib/stringified_hash_spec.rb
waistband-0.7.0 spec/lib/stringified_hash_spec.rb
waistband-0.4.2 spec/lib/stringified_hash_spec.rb
waistband-0.4.1 spec/lib/stringified_hash_spec.rb
waistband-0.4.0 spec/lib/stringified_hash_spec.rb
waistband-0.3.2 spec/lib/stringified_hash_spec.rb
waistband-0.3.1 spec/lib/stringified_hash_spec.rb
waistband-0.3.0 spec/lib/stringified_hash_spec.rb
waistband-0.2.5 spec/lib/stringified_hash_spec.rb
waistband-0.2.4 spec/lib/stringified_hash_spec.rb
waistband-0.2.3 spec/lib/stringified_hash_spec.rb
waistband-0.2.2 spec/lib/stringified_hash_spec.rb