Sha256: 3825b382a8a3769131c8998753be32de62b6fde5404ac453f6fd17ac29974daa

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

require 'samovar'
require 'stringio'

module Samovar::NestedSpec
	class InnerA < Samovar::Command
	end
	
	class InnerB < Samovar::Command
		options do
			option '--help'
		end
	end
	
	class Outer < Samovar::Command
		options do
			option '--help'
		end
		
		nested '<command>', {
			'inner-a' => InnerA,
			'inner-b' => InnerB,
		}, default: 'inner-b'
	end
	
	RSpec.describe Samovar::Nested do
		it "should select default nested command" do
			outer = Outer[]
			expect(outer.command).to be_kind_of(InnerB)
		end
		
		it "should select explicitly named nested command" do
			outer = Outer['inner-a']
			expect(outer.command).to be_kind_of(InnerA)
		end
		
		xit "should parse help option at outer level" do
			outer = Outer['inner-a', '--help']
			expect(outer.options[:help]).to_be truthy
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
samovar-1.10.0 spec/samovar/nested_spec.rb
samovar-1.9.2 spec/samovar/nested_spec.rb