Sha256: d666576e29b24913f81ccbc9356e913815f71211c1c5694a2b06a2c1a47c0c8a

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

require_relative '../../spec_helper'

describe AIPP::THash do
  context "non-circular dependencies" do
    subject do
      AIPP::THash[
        dns: %i(net),
        webserver: %i(dns logger),
        net: [],
        logger: []
      ]
    end

    describe :tsort do
      it "must compile the overall dependency list" do
        subject.tsort.must_equal %i(net dns logger webserver)
      end

      it "must compile partial dependency lists" do
        subject.tsort(:dns).must_equal %i(net dns)
        subject.tsort(:logger).must_equal %i(logger)
        subject.tsort(:webserver).must_equal %i(net dns logger webserver)
      end
    end
  end

  context "circular dependencies" do
    subject do
      AIPP::THash[
        dns: %i(net),
        webserver: %i(dns logger),
        net: %i(dns),
        logger: []
      ]
    end

    describe :tsort do
      it "must raise cyclic dependency error" do
        -> { subject.tsort }.must_raise TSort::Cyclic
        -> { subject.tsort(:dns) }.must_raise TSort::Cyclic
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aipp-0.2.4 spec/lib/aipp/t_hash_spec.rb
aipp-0.2.3 spec/lib/aipp/t_hash_spec.rb
aipp-0.2.2 spec/lib/aipp/t_hash_spec.rb
aipp-0.2.1 spec/lib/aipp/t_hash_spec.rb
aipp-0.2.0 spec/lib/aipp/t_hash_spec.rb