Sha256: ab48601c38b2eea44e085446c45bcdbb817ec7a3c1444915d803d9974b61e757

Contents?: true

Size: 860 Bytes

Versions: 10

Compression:

Stored size: 860 Bytes

Contents

require "spec_helper"

describe Mongoid::Extensions::Array::Conversions do

  describe "#mongoidize" do

    it "collects each of its attributes" do
      array = [
        Person.new(:_id => 1, :title => "Sir"),
        Person.new(:_id => 2, :title => "Madam")
      ]
      array.mongoidize.should ==
        [ HashWithIndifferentAccess.new({ :_id => 1, :title => "Sir", :age => 100, :_type => "Person", "blood_alcohol_content" => 0.0, :pets => false }),
          HashWithIndifferentAccess.new({ :_id => 2, :title => "Madam", :age => 100, :_type => "Person", "blood_alcohol_content" => 0.0, :pets => false }) ]
    end

  end

  describe "#get" do

    it "returns the array" do
      Array.get(["test"]).should == ["test"]
    end

  end

  describe "#set" do

    it "returns the array" do
      Array.set(["test"]).should == ["test"]
    end

  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.beta1 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-2.0.0.alpha spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.14 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.13 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.12 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.11 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.10 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.9 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.8 spec/unit/mongoid/extensions/array/conversions_spec.rb
mongoid-1.2.7 spec/unit/mongoid/extensions/array/conversions_spec.rb