Sha256: e26d1dbe3db37ad89b85ead72717787f6708919942ac2cd428c64942f6fea91c

Contents?: true

Size: 944 Bytes

Versions: 19

Compression:

Stored size: 944 Bytes

Contents

require 'spec_helper'
module Finitio
  describe SeqType, 'dress' do

    let(:type){ SeqType.new(byte) }

    subject{ type.dress(arg) }

    context 'with an empty array' do
      let(:arg){ [] }

      it{ should eq([]) }
    end

    context 'with a valid array' do
      let(:arg){ [12, 16] }

      it{ should eq([12, 16]) }
    end

    context 'with not a enumerable' do
      let(:arg){ "foo" }

      it 'should raise an error' do
        expect{
          subject
        }.to raise_error("Invalid [Byte] `foo`")
      end
    end

    context 'with an array with non bytes' do
      let(:arg){ [2, 4, -12] }

      subject{
        type.dress(arg) rescue $!
      }

      it 'should raise an error' do
        expect(subject).to be_a(TypeError)
        expect(subject.message).to eq("Invalid Byte `-12`")
      end

      it 'should have correct location' do
        expect(subject.location).to eq("2")
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/type/seq_type/test_dress.rb
finitio-0.11.4 spec/type/seq_type/test_dress.rb
finitio-0.11.3 spec/type/seq_type/test_dress.rb
finitio-0.11.2 spec/type/seq_type/test_dress.rb
finitio-0.11.1 spec/type/seq_type/test_dress.rb
finitio-0.10.0 spec/type/seq_type/test_dress.rb
finitio-0.9.1 spec/type/seq_type/test_dress.rb
finitio-0.9.0 spec/type/seq_type/test_dress.rb
finitio-0.8.0 spec/type/seq_type/test_dress.rb
finitio-0.7.0 spec/type/seq_type/test_dress.rb
finitio-0.7.0.pre.rc4 spec/type/seq_type/test_dress.rb
finitio-0.7.0.pre.rc3 spec/type/seq_type/test_dress.rb
finitio-0.7.0.pre.rc2 spec/type/seq_type/test_dress.rb
finitio-0.7.0.pre.rc1 spec/type/seq_type/test_dress.rb
finitio-0.6.1 spec/type/seq_type/test_dress.rb
finitio-0.6.0 spec/type/seq_type/test_dress.rb
finitio-0.5.2 spec/type/seq_type/test_dress.rb
finitio-0.5.1 spec/type/seq_type/test_dress.rb
finitio-0.5.0 spec/type/seq_type/test_dress.rb