Sha256: 5c63fb84d8c63e31fbfdada9b32455c82b050d95441ac072e355605e45c71542

Contents?: true

Size: 699 Bytes

Versions: 21

Compression:

Stored size: 699 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
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
mongo_doc-0.6.14 spec/attributes_accessor_spec.rb
mongo_doc-0.6.13 spec/attributes_accessor_spec.rb
mongo_doc-0.6.12 spec/attributes_accessor_spec.rb
mongo_doc-0.6.11 spec/attributes_accessor_spec.rb
mongo_doc-0.6.10 spec/attributes_accessor_spec.rb
mongo_doc-0.6.9 spec/attributes_accessor_spec.rb
mongo_doc-0.6.8 spec/attributes_accessor_spec.rb
mongo_doc-0.6.7 spec/attributes_accessor_spec.rb
mongo_doc-0.6.6 spec/attributes_accessor_spec.rb
mongo_doc-0.6.5 spec/attributes_accessor_spec.rb
mongo_doc-0.6.4 spec/attributes_accessor_spec.rb
mongo_doc_rails2-0.6.2 spec/attributes_accessor_spec.rb
mongo_doc-0.6.3 spec/attributes_accessor_spec.rb
mongo_doc-0.6.2 spec/attributes_accessor_spec.rb
mongo_doc-0.6.1 spec/attributes_accessor_spec.rb
mongo_doc-0.6.0 spec/attributes_accessor_spec.rb
mongo_doc_rails2-0.6.1 spec/attributes_accessor_spec.rb
mongo_doc-0.5.5 spec/attributes_accessor_spec.rb
mongo_doc-0.4.2 spec/attributes_accessor_spec.rb
mongo_doc-0.4.1 spec/attributes_accessor_spec.rb