Sha256: 97e7f49fd653d8bb0ab9fbbc34e4ed570cd15078060e7a2080b81b0f24987c52

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
require 'mida_vocabulary/propertydesc'

describe Mida::PropertyDesc, 'when initialized without a block' do
  before do
    @propertyDesc = Mida::PropertyDesc.new(3)
  end

  it '#to_h[:num] should equal num passed' do
    @propertyDesc.to_h[:num].should == 3
  end

  it '#to_h[:types] should equal DataType::Text' do
    @propertyDesc.to_h[:types].should == [Mida::DataType::Text]
  end
end

describe Mida::PropertyDesc, 'when initialized with a block with no specified types' do
  before do
    @propertyDesc = Mida::PropertyDesc.new(3) {}
  end

  it '#to_h[:types] should equal DataType::Text' do
    @propertyDesc.to_h[:types].should == [Mida::DataType::Text]
  end
end

describe Mida::PropertyDesc, 'when initialized with a block that specifies types with extract()' do
  before do
    @propertyDesc = Mida::PropertyDesc.new(3) { extract String, Array}
  end

  it '#to_h[:types] should equal [String, Array]' do
    @propertyDesc.to_h[:types].should == [String, Array]
  end
end

describe Mida::PropertyDesc, 'when initialized with a block that specifies types with types()' do
  before do
    @propertyDesc = nil
    @error = last_stderr do
      @propertyDesc = Mida::PropertyDesc.new(3) { types String, Array}
    end
  end

  it 'should warn on initialization if types() is used in the block' do
    @error.should eq("[DEPRECATION] Mida::PropertyDesc#types is deprecated.  "+
      "Please use Mida::PropertyDesc#extract instead."
    )
  end

  it '#to_h[:types] should equal [String, Array]' do
    @propertyDesc.to_h[:types].should == [String, Array]
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mida_vocabulary-0.2.2 spec/propertydesc_spec.rb
mida_vocabulary-0.2 spec/propertydesc_spec.rb
mida_vocabulary-0.1.3 spec/propertydesc_spec.rb
mida_vocabulary-0.1.2 spec/propertydesc_spec.rb
mida_vocabulary-0.1.1 spec/propertydesc_spec.rb
mida_vocabulary-0.1 spec/propertydesc_spec.rb