Sha256: e99fc1f859b0fdb9b240dbad7a5d8d63479ab6f9cfbd37660d24440c0b00e473

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 Bytes

Contents

require 'rspec'
module Qrb
  describe System, "fetch" do

    let(:system){ System.new }

    before do
      system.add_type(intType)
    end

    subject{ system.fetch(name) }

    context 'with an existing type name' do
      let(:name){ "intType" }

      it 'should return the type' do
        subject.should eq(intType)
      end
    end

    context 'with a non existing type name and no block' do
      let(:name){ "noSuchOne" }

      it 'should raise an error' do
        ->{
          subject
        }.should raise_error(KeyError, /noSuchOne/)
      end
    end

    context 'with a non existing type name and a block' do
      subject{
        system.fetch("noSuchOne"){ "bar" }
      }

      it 'should yield the block' do
        subject.should eq("bar")
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qrb-0.3.0 spec/unit/system/test_fetch.rb
qrb-0.2.0 spec/unit/system/test_fetch.rb
qrb-0.1.0 spec/unit/system/test_fetch.rb