spec/liquid_diagrams/utils_spec.rb in liquid-diagrams-0.3.0 vs spec/liquid_diagrams/utils_spec.rb in liquid-diagrams-0.4.0
- old
+ new
@@ -6,43 +6,53 @@
describe '.join' do
context 'with string input' do
it 'join the string with prefix' do
args = described_class.join('path', with: ' -I')
- expect(args).to eq ' -Ipath'
+ expect(args).to eq '-Ipath'
end
end
context 'with array input' do
it 'join the array with prefix' do
args = described_class.join(
%w[path1 path2], with: ' -I'
)
- expect(args).to eq ' -Ipath1 -Ipath2'
+ expect(args).to eq '-Ipath1 -Ipath2'
end
end
context 'with hash input' do
it 'join the hash with prefix' do
args = described_class.join(
{ color: 'red', size: '10' }, with: ' --'
) { |k, v| "#{k} #{v}" }
- expect(args).to eq ' --color red --size 10'
+ expect(args).to eq '--color red --size 10'
end
end
end
- describe '.merge' do
- it 'merge the hash' do
- hash = described_class.merge({ k1: 1, k2: 2 }, { k1: 11, k3: 13 })
+ describe '.build_options' do
+ let(:keys) { %i[color size] }
+ let(:config) { { color: :red, scale: 5 } }
- expect(hash).to eq({ k1: 11, k2: 2 })
+ it 'build options from config' do
+ expect(described_class.build_options(config, keys)).to eq '--color red'
end
end
+ describe '.build_flags' do
+ let(:keys) { %i[bold italic] }
+ let(:config) { { bold: true, center: true, italic: false } }
+
+ it 'build flags from config' do
+ expect(described_class.build_flags(config, keys)).to eq '--bold'
+ end
+ end
+
describe '.run_jar' do
it 'run jar in headless mode' do
command = described_class.run_jar('test.jar')
expect(command).to match '-Djava.awt.headless=true'
@@ -68,9 +78,11 @@
it 'parse inline options' do
input = 'a1=v1 a2="v2" a3="k3 v3"'
options = described_class.parse_inline_options(input)
- expect(options).to match a_hash_including(a1: 'v1', a2: 'v2', a3: 'k3 v3')
+ expect(options).to match a_hash_including(
+ 'a1' => 'v1', 'a2' => 'v2', 'a3' => 'k3 v3'
+ )
end
end
end