All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.virtus-1.0.5.spec.unit.virtus.attributes_reader_spec.rb Maven / Gradle / Ivy

The newest version!
require 'spec_helper'

describe Virtus, '#attributes' do

  shared_examples_for 'attribute hash' do
    it 'includes all attributes' do
      subject.attributes = { :test => 'Hello World', :test_priv => 'Yo' }

      expect(subject.attributes).to eql(:test => 'Hello World')
    end
  end

  context 'with a class' do
    let(:model) {
      Class.new {
        include Virtus

        attribute :test,      String
        attribute :test_priv, String, :reader => :private
      }
    }

    it_behaves_like 'attribute hash' do
      subject { model.new }
    end
  end

  context 'with an instance' do
    subject { model.new }

    let(:model) { Class.new }

    before do
      subject.extend(Virtus)
      subject.attribute :test,      String
      subject.attribute :test_priv, String, :reader => :private
    end

    it_behaves_like 'attribute hash'
  end
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy