Sha256: 4d93b1b3d3bb39e077376de5db06c3f7bf893aea89de3dc95da1f5ef8cd238e0

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# coding: utf-8
require File.expand_path('../../../spec_helper', __FILE__)

describe Agig::OptParser do

  describe '#self.cast' do
    let(:opts) { { host: "localhost" } }
    subject { Agig::OptParser.cast opts }

    context 'when string given' do
      it { expect(subject[:host]).to be_an_instance_of String }
    end
    context 'when digit in first letter given' do
      let(:opts) { { port: "16705" } }
      it { expect(subject[:port]).to be_an_instance_of Fixnum }
    end
    context 'when decimal in first letter given' do
      let(:opts) { { interval: "60.5" } }
      it { expect(subject[:interval]).to be_an_instance_of Float }
    end
    context 'when nil given' do
      let(:opts) { { log: nil } }
      it { expect(subject[:log]).to be_truthy }
    end
    context 'when true given' do
      let(:opts) { { debug: true } }
      it { expect(subject[:debug]).to be_truthy }
    end
    context 'when false given' do
      let(:opts) { { foreground: false } }
      it { expect(subject[:foreground]).to be_falsey }
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
agig-0.2.1 spec/lib/agig/optparse_spec.rb
agig-0.2.0 spec/lib/agig/optparse_spec.rb