Sha256: e83d4a0fcaf5c7878c37775eb4390a7a2f293a4605475f6b71befa49adbd590f

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

require 'spec_helper'

describe Virtus::ModuleExtensions, '#attribute' do
  subject { object.attribute(name, type, options) }

  let(:object)  { Module.new              }
  let(:name)    { :name                   }
  let(:type)    { String                  }
  let(:options) { { :default => default } }
  let(:default) { 'John Doe'.freeze       }

  before do
    object.extend(Virtus::ModuleExtensions)
  end

  it { should be(object) }

  it 'tracks the attribute for extension' do
    subject
    instance = Object.new
    instance.extend(object)
    instance.attributes[name].should eql(default)
  end

  it 'tracks the attribute for inclusion' do
    subject
    klass = Class.new
    klass.send(:include, object)
    klass.attribute_set[name].should eql(Virtus::Attribute::String.new(name, options))
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
virtus-0.5.5 spec/unit/virtus/module_extensions/attribute_spec.rb
virtus-0.5.4 spec/unit/virtus/module_extensions/attribute_spec.rb
virtus-0.5.3 spec/unit/virtus/module_extensions/attribute_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/module_extensions/attribute_spec.rb
virtus-0.5.2 spec/unit/virtus/module_extensions/attribute_spec.rb