Sha256: 7ca7a4bb648943ec4c7c82ad2c9418c65906ea8bec5f0341ef2c2b898193eb00

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/core_ext/hash/options'

RSpec.describe '#to_options' do
  it 'converts hash to array of command line options' do
    hash = { }

    expect(hash.to_options).to be_kind_of Array
  end

  it 'converts true value' do
    hash = { 
      opt1: true
    }

    expect(hash.to_options).to eq %w{ --opt1 }
  end

  it 'converts false value' do
    hash = { 
      opt1: false
    }

    expect(hash.to_options).to eq %w{ --no-opt1 }
  end

  it 'converts integervalue' do
    hash = { 
      opt1: 1
    }

    expect(hash.to_options).to eq %w{ --opt1 1 }
  end

  it 'converts string value' do
    hash = { 
      opt1: 'string'
    }

    expect(hash.to_options).to eq %w{ --opt1 string }
  end

  it 'converts symbol value' do
    hash = { 
      opt1: :string
    }

    expect(hash.to_options).to eq %w{ --opt1 string }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.6.40 spec/core_ext/hash/options_spec.rb