Merge pull request #8526 from SeekingMeaning/version/to_str

version: allow implicitly converting tokens to strings
This commit is contained in:
Dawid Dziurla 2020-08-28 20:49:43 +02:00 committed by GitHub
commit 257e4cc7ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -38,6 +38,12 @@ describe Version::Token do
expect(v <=> Object.new).to be nil
expect { v > Object.new }.to raise_error(ArgumentError)
end
describe "#to_str" do
it "implicitly converts token to string" do
expect(String.try_convert(described_class.new("foo"))).not_to be nil
end
end
end
describe Version::NULL do

View File

@ -65,6 +65,7 @@ class Version
def to_s
value.to_s
end
alias to_str to_s
def numeric?
false