Sha256: 8c70798cce4b5f8592031d78506ed42f5b949dcd01495768071776f718124996

Contents?: true

Size: 943 Bytes

Versions: 47

Compression:

Stored size: 943 Bytes

Contents

# encoding:utf-8
require './test/test_helper'
require './test/support/hash_with_indifferent_access'

class HashWithIndifferentAccessTest < Test::Unit::TestCase
  include BSON

  def setup
    @encoder = BSON::BSON_CODER
  end

  def test_document
    doc = HashWithIndifferentAccess.new
    doc['foo'] = 1
    doc['bar'] = 'baz'

    bson = @encoder.serialize(doc)
    assert_equal doc, @encoder.deserialize(bson.to_s)
  end

  def test_embedded_document
    jimmy = HashWithIndifferentAccess.new
    jimmy['name']     = 'Jimmy'
    jimmy['species'] = 'Siberian Husky'

    stats = HashWithIndifferentAccess.new
    stats['eyes'] = 'blue'

    person = HashWithIndifferentAccess.new
    person['_id'] = BSON::ObjectId.new
    person['name'] = 'Mr. Pet Lover'
    person['pets'] = [jimmy, {'name' => 'Sasha'}]
    person['stats'] = stats

    bson = @encoder.serialize(person)
    assert_equal person, @encoder.deserialize(bson.to_s)
  end
end

Version data entries

47 entries across 46 versions & 5 rubygems

Version Path
vanity-1.7.1 vendor/ruby/1.9.1/gems/bson-1.3.1/test/bson/hash_with_indifferent_access_test.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/mongo-1.3.1/test/bson/hash_with_indifferent_access_test.rb
jonbell-mongo-1.3.1.2 test/bson/hash_with_indifferent_access_test.rb
mongo-lyon-1.2.4 test/bson/hash_with_indifferent_access_test.rb
bson-1.3.1-jruby test/bson/hash_with_indifferent_access_test.rb
bson-1.3.1 test/bson/hash_with_indifferent_access_test.rb
mongo-1.3.1 test/bson/hash_with_indifferent_access_test.rb
bson-1.3.0-jruby test/bson/hash_with_indifferent_access_test.rb
bson-1.3.0 test/bson/hash_with_indifferent_access_test.rb
mongo-1.3.0 test/bson/hash_with_indifferent_access_test.rb
bson-1.3.0.rc0-jruby test/bson/hash_with_indifferent_access_test.rb
bson-1.3.0.rc0 test/bson/hash_with_indifferent_access_test.rb
mongo-1.3.0.rc0 test/bson/hash_with_indifferent_access_test.rb
bson-1.2.4-jruby test/bson/hash_with_indifferent_access_test.rb
bson-1.2.4 test/bson/hash_with_indifferent_access_test.rb
mongo-1.2.4 test/bson/hash_with_indifferent_access_test.rb
bson-1.2.3-jruby test/bson/hash_with_indifferent_access_test.rb
bson-1.2.3 test/bson/hash_with_indifferent_access_test.rb
mongo-1.2.3 test/bson/hash_with_indifferent_access_test.rb
mongo-1.2.2 test/bson/hash_with_indifferent_access_test.rb