Skip to content

Commit 4ed44cd

Browse files
committed
Add tests to fulfill argument/switch/flag proxy to command block
1 parent e8ff3b6 commit 4ed44cd

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

spec/lib/git_commander/command_spec.rb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,41 @@
3434
expect(output).to have_received(:puts).with "I'm on a Lotus Evora!"
3535
end
3636

37-
it "runs the block registered to it passing arguments and options"
38-
it "runs the block registered to it passing options with defaults"
37+
it "runs the block registered to it passing arguments and options" do
38+
command = described_class.new(
39+
:wtf,
40+
output: output,
41+
arguments: [{ name: :verb }],
42+
flags: [{ name: :make, default: "Lotus" }],
43+
switches: [{ name: :model }]
44+
) do |params|
45+
say "I'm in a #{[params[:verb], params[:make], params[:model]].compact.join(" ")}!"
46+
end
47+
command.run [
48+
GitCommander::Command::Option.new(name: :verb, value: "cool"),
49+
GitCommander::Command::Option.new(name: :model, value: "Evora")
50+
]
51+
expect(output).to have_received(:puts).with "I'm in a cool Lotus Evora!"
52+
end
53+
54+
it "runs the block registered to it passing options with defaults" do
55+
command = described_class.new(
56+
:wtf,
57+
output: output,
58+
flags: [{ name: :make, default: "Lotus" }]
59+
) do |params|
60+
say "I'm in a #{params[:make]}!"
61+
end
62+
command.run
63+
expect(output).to have_received(:puts).with "I'm in a Lotus!"
64+
end
3965

4066
it "can add output" do
4167
command = described_class.new(:wtf, output: output)
4268
command.say "Ooh eeh what's up with that"
4369
expect(output).to have_received(:puts).with "Ooh eeh what's up with that"
4470
end
4571

46-
it "raises an error if no arguments, flags, or switches exist for the params passed"
47-
4872
it "can output a help message" do
4973
full_command = described_class.new(
5074
:start,

0 commit comments

Comments
 (0)