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.4.0 spec/attributes_accessor_spec.rb