Sha256: c5e155a07361cf3397191f1e101eef971105d1b8b962d360ffdbe3b24f49d1cd

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

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

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

    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
qrb-0.2.0 spec/unit/type/ad_type/test_initialize.rb
qrb-0.1.0 spec/unit/type/ad_type/test_initialize.rb