Sha256: ac0c1769668949e86c44f28c0df32606c3eaf316d7eb04883d20efaf50329bf5

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 Bytes

Contents

require 'rspec'
module Qrb
  describe System, "add_type" do

    let(:system){ System.new }

    subject{ system.add_type(type) }

    context 'with a valid type' do
      let(:type){ intType }

      it 'should return the created type' do
        subject.should be(type)
      end

      it 'should add the type' do
        subject
        system[type.name].should be(type)
      end
    end

    context 'with an invalid type' do
      let(:type){ "foo" }

      it 'should raise an error' do
        ->{
          subject
        }.should raise_error(ArgumentError, "Qrb::Type expected, got `foo`")
      end
    end

    context 'with a duplicate type name' do
      let(:type){ intType }

      before do
        system.add_type(type)
      end

      it 'should raise an error' do
        ->{
          subject
        }.should raise_error(Qrb::Error, "Duplicate type name `intType`")
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/system/test_add_type.rb
qrb-0.2.0 spec/unit/system/test_add_type.rb
qrb-0.1.0 spec/unit/system/test_add_type.rb