implement :boolean option flag
This commit is contained in:
1 parent
f74253844b
commit
a78ee7275e
2 files changed
+32
-3
No files matched your search
+19
-1
@@ -1,7 +1,7 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Yawpa do
|
||||
describe 'parse' do
|
||||
describe ".parse" do
|
||||
it "returns everything as arguments when no options present" do
|
||||
options = { }
|
||||
params = ['one', 'two', 'three', 'four']
|
||||
@@ -213,5 +213,23 @@ describe Yawpa do
|
||||
expect(opts[:two]).to be_falsey
|
||||
expect(args).to eq(['arg', '--two'])
|
||||
end
|
||||
|
||||
it "supports :boolean option flag" do
|
||||
options = {
|
||||
push: {boolean: true},
|
||||
}
|
||||
|
||||
opts, args = Yawpa.parse(%w[hi], options)
|
||||
expect(opts).to eq({})
|
||||
expect(args).to eq(%w[hi])
|
||||
|
||||
opts, args = Yawpa.parse(%w[--push one two], options)
|
||||
expect(opts).to eq(push: true)
|
||||
expect(args).to eq(%w[one two])
|
||||
|
||||
opts, args = Yawpa.parse(%w[arg --nopush], options)
|
||||
expect(opts).to eq(push: false)
|
||||
expect(args).to eq(%w[arg])
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user