Sha256: 8b84f05892adb21be8e3c11131f68a085c200d8579cb32de8ce301b9dc42a606
Contents?: true
Size: 1.35 KB
Versions: 31
Compression:
Stored size: 1.35 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
31 entries across 31 versions & 1 rubygems