Skip to content

Commit

Permalink
Add a test to ensure no conversion of parameters without value
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Dec 28, 2022
1 parent 33b874c commit 06d40bb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions spec/unit/param_conversion_spec.rb
Expand Up @@ -7,6 +7,16 @@
expect(described_class[param, "12"].value).to eq(12)
end

it "skips parameter conversion when value is nil" do
param = TTY::Option::Parameter::Argument.create(:foo, convert: :int)

result = described_class[param, nil]

expect(result.success?).to eq(true)
expect(result.value).to eq(nil)
expect(result.error).to eq(nil)
end

it "fails to convert parameter value to expected type" do
param = TTY::Option::Parameter::Argument.create(:foo, convert: :int)

Expand Down

0 comments on commit 06d40bb

Please sign in to comment.