-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Output: select fields you want for listings
Closes #24. There is one gotcha. When user writes the option mistakenly like `--fields`, Thor automatically parses it the same way as if user had written `--fields=fields`, even though the `fields` option is configured to type `string`, so it should not be treated like a switch imho. Seems to me more like a bug than a feature, but I don't know how to write a *clean* wrokaround, so I'd rather keep it this way for now.
- Loading branch information
Showing
6 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'aeolus_cli/common_cli' | ||
|
||
describe AeolusCli::CommonCli do | ||
let(:common_cli) { AeolusCli::CommonCli.new() } | ||
|
||
context "#resource_fields" do | ||
context "non-empty fields" do | ||
subject { common_cli.send(:resource_fields, "name,status,is_cool") } | ||
it { should == [:name, :status, :is_cool] } | ||
end | ||
|
||
context "empty fields" do | ||
subject { common_cli.send(:resource_fields, "") } | ||
it do | ||
expect { subject }.to raise_error Thor::MalformattedArgumentError | ||
end | ||
end | ||
|
||
context "nil fields" do | ||
subject { common_cli.send(:resource_fields, nil) } | ||
it { should == nil } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'aeolus_cli/formatting' | ||
|
||
describe AeolusCli::Formatting do | ||
let(:formatting) { AeolusCli::Formatting } | ||
let(:shell) { double('shell') } | ||
|
||
context ".create_format" do | ||
subject { formatting.create_format(shell, { :format => 'human' }) } | ||
let(:human_format) { double('human format') } | ||
let(:human_format_class) do | ||
double('human format class').tap do |clazz| | ||
clazz.stub(:new).with(shell).and_return(human_format) | ||
end | ||
end | ||
|
||
before do | ||
formatting.should_receive(:require).with("aeolus_cli/formatting/human_format").and_return(true) | ||
formatting.should_receive(:const_get).with("HumanFormat").and_return(human_format_class) | ||
end | ||
|
||
it { should == human_format } | ||
end | ||
end |