test/lib/vedeu/configuration_test.rb in vedeu-0.1.17 vs test/lib/vedeu/configuration_test.rb in vedeu-0.1.18

- old
+ new

@@ -1,31 +1,138 @@ require 'test_helper' module Vedeu describe Configuration do - describe '#configure' do - it 'returns an empty collection when no options are set' do - Configuration.configure([]).must_equal({}) + before { Configuration.reset } + + after { Configuration.reset } + + describe '#colour_mode' do + it 'returns the value of the colour_mode option' do + ENV['VEDEU_TERM'] = 'xterm-truecolor' + Configuration.colour_mode.must_equal(16777216) end - it 'returns the options which instructs Vedeu to run once' do + it '--colour-mode' do + Configuration.configure(['--colour-mode', '16']) + Configuration.colour_mode.must_equal(16) + end + + it '--colour-mode' do + Configuration.configure(['--colour-mode', '256']) + Configuration.colour_mode.must_equal(256) + end + + it '--colour-mode' do + Configuration.configure(['--colour-mode', '348']) + Configuration.colour_mode.must_equal(8) + end + end + + describe '#debug?' do + it 'returns the value of the debug option' do + Configuration.debug?.must_equal(false) + end + + it '--debug' do + Configuration.configure(['--debug']) + Configuration.debug?.must_equal(true) + end + end + + describe '#interactive?' do + it 'returns the value of the interactive option' do + Configuration.interactive?.must_equal(true) + end + + it '--interactive' do + Configuration.configure(['--interactive']) + Configuration.interactive?.must_equal(true) + end + + it '--noninteractive' do + Configuration.configure(['--noninteractive']) + Configuration.interactive?.must_equal(false) + end + + it '--standalone' do + Configuration.configure(['--standalone']) + Configuration.interactive?.must_equal(false) + end + end + + describe '#once?' do + it 'returns the value of the once option' do + Configuration.once?.must_equal(false) + end + + it '--run-once' do Configuration.configure(['--run-once']) - .must_equal({ interactive: false }) + Configuration.once?.must_equal(true) end - it 'returns the options which instructs Vedeu to run in cooked mode' do + it '--run-many' do + Configuration.configure(['--run-many']) + Configuration.once?.must_equal(false) + end + end + + describe '#terminal_mode' do + it 'returns the value of the mode option' do + Configuration.terminal_mode.must_equal(:raw) + end + + it '--cooked' do Configuration.configure(['--cooked']) - .must_equal({ mode: :cooked }) + Configuration.terminal_mode.must_equal(:cooked) end - it 'returns the options which instructs Vedeu to run in raw mode' do + it '--raw' do Configuration.configure(['--raw']) - .must_equal({ mode: :raw }) + Configuration.terminal_mode.must_equal(:raw) end + end - it 'returns the options which instructs Vedeu to run with debugging on' do - Configuration.configure(['--debug']) - .must_equal({ debug: true }) + describe '#trace?' do + it 'returns the value of the trace option' do + Configuration.trace?.must_equal(false) end + + it '--trace' do + Configuration.configure(['--trace']) + Configuration.trace?.must_equal(true) + end end + + describe '#options' do + it 'returns the options configured' do + Configuration.options.must_equal( + { + colour_mode: 16777216, + debug: false, + interactive: true, + once: false, + terminal_mode: :raw, + trace: false + } + ) + end + end + + describe 'exploring multiple options set' do + it 'returns the options correctly configured' do + Configuration.configure(['--standalone', '--run-once']) + Configuration.options.must_equal( + { + interactive: false, + once: true, + colour_mode: 16777216, + debug: false, + terminal_mode: :raw, + trace: false + } + ) + end + end + end end