Sha256: e0cfda499bf319676409a4ac2bb64e113f1c2974fe9be7ba84068cb7fe3a9093

Contents?: true

Size: 680 Bytes

Versions: 2

Compression:

Stored size: 680 Bytes

Contents

require 'spec_helper'

describe Interfaces::TypedAccessors do
  describe ClassWithTypedAttributes do
    let(:instance) { ClassWithTypedAttributes.new }

    it 'should convert an object to the correct type when it is assigned' do
      instance.field1 = FullyImplimentedClass.new
      instance.field1.should be_a_kind_of(TestInterface)
    end

    it 'should throw an exception if an object that does not conform to the interface is passed' do
      expect { instance.field1 = Object.new }.to raise_error(Interfaces::NonConformingObjectError)
    end

    it 'should allow nil to be assigned' do
      instance.field1 = nil
      instance.field1.should be_nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
interfaces-0.2.0 spec/typed_accessor_spec.rb
interfaces-0.0.2.pre spec/typed_accessor_spec.rb