spec/command_spec.rb in mercenary-0.1.0 vs spec/command_spec.rb in mercenary-0.2.0

- old
+ new

@@ -2,17 +2,22 @@ describe(Mercenary::Command) do context "a basic command" do let(:command) { Mercenary::Command.new(:my_name) } + let(:parent) { Mercenary::Command.new(:my_parent) } + let(:with_sub) do + c = Mercenary::Command.new(:i_have_subcommand) + add_sub.call(c) + c + end let(:command_with_parent) do Mercenary::Command.new( :i_have_parent, parent ) end - let(:parent) { Mercenary::Command.new(:my_parent) } let(:add_sub) do Proc.new do |c| c.command(:sub_command) { |p| } end end @@ -47,9 +52,18 @@ name = "show_drafts" opt = ['--drafts', 'Render posts in the _drafts folder'] command.option name, *opt expect(command.options).to eq([opt]) expect(command.map).to include({opt.first => name}) + end + + it "raises an ArgumentError if I specify a default_command that isn't there" do + c = command # some weird NameError with the block below? + expect { c.default_command(:nope) }.to raise_error(ArgumentError) + end + + it "sets the default_command" do + expect(with_sub.default_command(:sub_command).name).to eq(:sub_command) end end end