Sha256: f3905ca73c48393d79f3a3ee8cec06e806fd7dcf1ebf350b26757b145a55eeb8

Contents?: true

Size: 815 Bytes

Versions: 11

Compression:

Stored size: 815 Bytes

Contents

require 'spec_helper'

describe "MongoDoc::Attributes attributes accessor" do
  class AttributesTest
    include MongoDoc::Attributes

    attr_accessor :name
    attr_accessor :age
    attr_accessor :birthdate, :type => Date
  end

  context "#attributes" do
    subject do
      AttributesTest.new.attributes
    end

    it "returns a hash of the given attributes" do
      should have_key(:name)
      should have_key(:age)
      should have_key(:birthdate)
    end
  end

  context "#attributes=" do
    let(:object) { AttributesTest.new }

    it "sets attributes from a hash" do
      name = 'name'
      object.attributes = {:name => name}
      object.name.should == name
    end

    it "ignores a nil" do
      expect do
        object.attributes = nil
      end.should_not raise_error
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongo_doc-0.6.26 spec/attributes_accessor_spec.rb
mongo_doc-0.6.25 spec/attributes_accessor_spec.rb
mongo_doc-0.6.23 spec/attributes_accessor_spec.rb
mongo_doc-0.6.22 spec/attributes_accessor_spec.rb
mongo_doc-0.6.21 spec/attributes_accessor_spec.rb
mongo_doc-0.6.20 spec/attributes_accessor_spec.rb
mongo_doc-0.6.19 spec/attributes_accessor_spec.rb
mongo_doc-0.6.18 spec/attributes_accessor_spec.rb
mongo_doc-0.6.17 spec/attributes_accessor_spec.rb
mongo_doc-0.6.16 spec/attributes_accessor_spec.rb
mongo_doc-0.6.15 spec/attributes_accessor_spec.rb