Sha256: 85d93f10b472c3c666e3cc7ced6c8c77fe68f3c6f6781ed838b292c612ea2fe1

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

require_relative '../lib/rationalist'
require 'minitest/autorun'
require 'minitest/expectations'

describe 'default bool' do
  it 'boolean default true' do
    argv = Rationalist.parse([], {
        boolean: 'sometrue',
        default: { sometrue: true }
    });
    argv[:sometrue].must_equal true
  end

  it 'boolean default false' do
    argv = Rationalist.parse([], {
        boolean: 'somefalse',
        default: { somefalse: false }
    });
    argv[:somefalse].must_equal false
  end

  it 'boolean default to nil' do
    argv = Rationalist.parse([], {
        boolean: 'maybe',
        default: { maybe: nil }
    });
    argv[:maybe].must_equal nil
    argv = Rationalist.parse(['--maybe'], {
        boolean: 'maybe',
        default: { maybe: nil }
    });
    argv[:maybe].must_equal true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rationalist-2.0.1 spec/default_bool_spec.rb
rationalist-2.0.0 spec/default_bool_spec.rb