Sha256: 2ac233043088532363ae3ce85fa5955b9de37220f8f30b8c30492056e5785caa

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

require 'spec_helper'
module Finitio
  describe AdType, 'initialize' do

    subject{
      AdType.new(Color, rgb: [intType,   Color.method(:rgb), Finitio::IDENTITY ],
                        hex: [floatType, Color.method(:hex), Finitio::IDENTITY ])
    }

    context 'with valid arguments' do
      it{ should be_a(AdType) }

      it 'should set the instance variables' do
        subject.ruby_type.should be(Color)
        subject.contracts.should be_a(Hash)
      end
    end

    context 'with invalid arguments (I)' do
      subject{ AdType.new("foo", {}) }

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

    context 'with invalid arguments (II)' do
      subject{ AdType.new(Object, "bar") }

      it 'should raise an error' do
        ->{
          subject
        }.should raise_error(ArgumentError, 'Hash expected, got `bar`')
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/type/ad_type/test_initialize.rb
finitio-0.4.0 spec/unit/type/ad_type/test_initialize.rb