Sha256: 441bfe46d8a2991f07f3f22d482c0500d783c0b47ce45657e61c22f6df58e318

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require_relative '../spec_helper'
require_relative '../../lib/kamerling/addr'
require_relative '../../lib/kamerling/settings'

module Kamerling
  describe Settings do
    let(:args) { %w(--db db --host 0.0.0.0 --http 2009 --tcp 1981 --udp 1979) }

    describe '.new' do
      it 'has sane defaults' do
        Settings.new([]).db.must_equal   'sqlite::memory:'
        Settings.new([]).host.must_equal '127.0.0.1'
      end

      it 'parses the passed settings' do
        settings = Settings.new(args)
        settings.db.must_equal   'db'
        settings.host.must_equal '0.0.0.0'
        settings.http.must_equal 2009
        settings.tcp.must_equal  1981
        settings.udp.must_equal  1979
      end
    end

    describe '#server_addrs' do
      it 'returns the server Addrs' do
        Settings.new([]).server_addrs.must_equal({})
        Settings.new(args).server_addrs.must_equal(
          http: Addr['0.0.0.0', 2009, :TCP],
          tcp:  Addr['0.0.0.0', 1981, :TCP],
          udp:  Addr['0.0.0.0', 1979, :UDP],
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kamerling-0.0.3 spec/kamerling/settings_spec.rb