Sha256: 56632bbb3af37e376841b01037387d145e9a401027f52ed84e7d145d0def4627
Contents?: true
Size: 1.33 KB
Versions: 56
Compression:
Stored size: 1.33 KB
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 it 'handles umlauts as well' do hash = { 'öäopt1' => 'string' } expect(hash.to_options).to eq %w(--opt1 string) end it 'handles special characters as well' do hash = { "$o p\tt1" => 'string' } expect(hash.to_options).to eq %w(--opt1 string) end it 'handles special characters in value as well' do hash = { opt1: 'string$string string' } expect(hash.to_options).to eq ['--opt1', 'string\$string\ string'] end end
Version data entries
56 entries across 56 versions & 1 rubygems