Skip to content

Commit

Permalink
Change to make keyword optional by default
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Mar 24, 2020
1 parent 659411c commit 4375bb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tty/option/parameter/keyword.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module TTY
module Option
class Parameter
class Keyword < Parameter
def required?
@settings.fetch(:required) { false }
end
end
end # Parameter
end # Option
Expand Down
12 changes: 12 additions & 0 deletions spec/unit/parameter/keyword_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

RSpec.describe TTY::Option::Parameter::Keyword do
context "required/optional setting" do
it "sets keyword presence optional by default" do
kwarg = described_class.new(:foo)

expect(kwarg.required?).to eq(false)
expect(kwarg.optional?).to eq(true)
end
end
end

0 comments on commit 4375bb9

Please sign in to comment.