Sha256: 0313850e956a81bff5004ad8d18d9e75e5214cb6c9c21e5095a1cd9020e5add9

Contents?: true

Size: 969 Bytes

Versions: 1

Compression:

Stored size: 969 Bytes

Contents

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

    subject{
      AdType.new(Color, rgb: [intType,   Color.method(:rgb), Qrb::IDENTITY ],
                        hex: [floatType, Color.method(:hex), Qrb::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

1 entries across 1 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/type/ad_type/test_initialize.rb