Sha256: 6671fdd210a9c53eaedbe89126270170e25997aa846658bd519eea71c9f0b95d

Contents?: true

Size: 1.74 KB

Versions: 19

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'
module Finitio
  describe SubType, "dress" do

    let(:type){ SubType.new(intType, [byte_full], "byte") }

    subject{ type.dress(arg) }

    context 'with an valid Integer' do
      let(:arg){ 12 }

      it{ should be(arg) }
    end

    context 'when raising an Error' do

      subject do
        type.dress(arg) rescue $!
      end

      context 'with a Float' do
        let(:arg){ 12.0 }

        it 'should raise an Error' do
          expect(subject).to be_a(TypeError)
          expect(subject.message).to eq("Invalid byte `12.0`")
        end

        it "should have the proper cause from super type's up" do
          expect(subject.cause).to be_a(TypeError)
          expect(subject.cause.message).to eq("Invalid intType `12.0`")
        end

        it "should have an empty location" do
          expect(subject.location).to eq('')
        end
      end

      context 'with a negative integer' do
        let(:arg){ -12 }

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

        it "should have no cause" do
          expect(subject.cause).to be_nil
        end

        it "should have an empty location" do
          expect(subject.location).to eq('')
        end
      end

      context 'with a non small integer' do
        let(:arg){ 1000 }

        it 'should raise an Error' do
          expect(subject).to be_a(TypeError)
          expect(subject.message).to eq("Invalid byte `1000`")
        end

        it "should have no cause" do
          expect(subject.cause).to be_nil
        end

        it "should have an empty location" do
          expect(subject.location).to eq('')
        end
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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