spec/lib/optparse_spec.rb in hieracles-0.1.5 vs spec/lib/optparse_spec.rb in hieracles-0.1.6

- old
+ new

@@ -30,11 +30,11 @@ it 'populates options' do expect(subject.options).to eq expected_options end end - context 'with funny arguments' do + context 'with funnily ordered arguments' do let(:array) { ['arg1', '-u', 'path/to/config-file', 'arg2', '-f', 'thatformat'] } let(:expected_payload) { ['arg1', 'arg2'] } let(:expected_options) do { format: 'thatformat' } end @@ -46,11 +46,11 @@ expect(subject.options).to eq expected_options end end context 'with arguments in alternative syntax' do - let(:array) { ['arg1', 'arg2', '-config', 'path/to/config-file', '-format', 'thatformat'] } + let(:array) { ['arg1', 'arg2', '-config', 'path/to/config-file', '--format', 'thatformat'] } let(:expected_payload) { ['arg1', 'arg2'] } let(:expected_options) do { config: 'path/to/config-file', format: 'thatformat' } end subject { Hieracles::Optparse.new array } @@ -59,7 +59,25 @@ end it 'populates options' do expect(subject.options).to eq expected_options end end + + + context 'with arguments containing boolean element' do + let(:array) { ['arg1', 'arg2', '-i', '-format', 'thatformat'] } + let(:expected_payload) { ['arg1', 'arg2'] } + let(:expected_options) do + { format: 'thatformat', interactive: true } + end + subject { Hieracles::Optparse.new array } + it "populates payload" do + expect(subject.payload).to eq expected_payload + end + it 'populates options' do + expect(subject.options).to eq expected_options + end + end + + end end