spec/command_spec.rb in mercenary-0.2.1 vs spec/command_spec.rb in mercenary-0.3.0
- old
+ new
@@ -33,10 +33,16 @@
it "can create subcommands" do
expect(add_sub.call(command)).to be_a(Mercenary::Command)
expect(add_sub.call(command).parent).to eq(command)
end
+ it "can set its version" do
+ version = "1.4.2"
+ command.version version
+ expect(command.version).to eq(version)
+ end
+
it "can set its syntax" do
syntax_string = "my_name [options]"
cmd = described_class.new(:my_name)
cmd.syntax syntax_string
expect(cmd.syntax).to eq(syntax_string)
@@ -48,13 +54,23 @@
expect(command.description).to eq(desc)
end
it "can set its options" do
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})
+ opts = ['--drafts', 'Render posts in the _drafts folder']
+ option = Mercenary::Option.new(name, opts)
+ command.option name, *opts
+ expect(command.options).to eql([option])
+ expect(command.map).to include({option.hash => name})
+ end
+
+ it "knows its full name" do
+ expect(command_with_parent.full_name).to eql("my_parent i_have_parent")
+ end
+
+ it "knows its identity" do
+ command_with_parent.version '1.8.7'
+ expect(command_with_parent.identity).to eql("my_parent i_have_parent 1.8.7")
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)