Sha256: 83fb4fa3d9661c2921f706264324f218d5362a41162d16efa5f86cb38e9fa861

Contents?: true

Size: 700 Bytes

Versions: 3

Compression:

Stored size: 700 Bytes

Contents

require 'spec_helper'

describe Virtus do
  let(:model) do
    Class.new do
      include Virtus

      attribute :name,  String
      attribute :age,   Integer
      attribute :email, String, :accessor => :private
    end
  end

  let(:object) do
    model.new(attributes)
  end

  let(:attributes) do
    { :name => 'john', :age => 28 }
  end

  describe '#attributes' do
    it "returns a hash of attributes" do
      object.attributes.should eql(attributes)
    end
  end

  describe "#attributes=" do
    before do
      object.attributes = attributes
    end

    it "sets attribute values for publicly accessible attributes" do
      object.attributes.should eql(attributes)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
virtus-0.0.5 spec/unit/virtus/instance_methods/attributes_spec.rb
virtus-0.0.4 spec/unit/virtus/instance_methods/attributes_spec.rb
virtus-0.0.3 spec/unit/virtus/instance_methods/attributes_spec.rb