|
34 | 34 | expect(output).to have_received(:puts).with "I'm on a Lotus Evora!"
|
35 | 35 | end
|
36 | 36 |
|
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 |
39 | 65 |
|
40 | 66 | it "can add output" do
|
41 | 67 | command = described_class.new(:wtf, output: output)
|
42 | 68 | command.say "Ooh eeh what's up with that"
|
43 | 69 | expect(output).to have_received(:puts).with "Ooh eeh what's up with that"
|
44 | 70 | end
|
45 | 71 |
|
46 |
| - it "raises an error if no arguments, flags, or switches exist for the params passed" |
47 |
| - |
48 | 72 | it "can output a help message" do
|
49 | 73 | full_command = described_class.new(
|
50 | 74 | :start,
|
|
0 commit comments