Sha256: 5e999495e631838939b12aadae030bc2ceb5d97521bd6645c2a9f16b38dc13c1

Contents?: true

Size: 706 Bytes

Versions: 13

Compression:

Stored size: 706 Bytes

Contents

require 'spec_helper'

describe Virtus::ClassMethods, '#const_missing' do
  let(:object) { Class.new { extend Virtus::ClassMethods } }

  context 'with a constant name that is known' do
    subject { object.class_eval 'String' }

    it 'returns the constant' do
      subject.should be(String)
    end
  end

  context 'with a constant name that corresponds to a Virtus::Attribute' do
    subject { object.class_eval 'Boolean' }

    it 'determines the correct type' do
      subject.should be(Virtus::Attribute::Boolean)
    end
  end

  context 'with a constant name that is unknown' do
    subject { object.class_eval 'Unknown' }

    specify { expect { subject }.to raise_error(NameError) }
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
virtus-0.5.5 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.5.4 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.5.3 spec/unit/virtus/class_methods/const_missing_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.5.2 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.5.1 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.5.0 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.4.2 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.4.1 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.4.0 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.3.0 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.2.0 spec/unit/virtus/class_methods/const_missing_spec.rb
virtus-0.1.0 spec/unit/virtus/class_methods/const_missing_spec.rb