Sha256: 016970ba3b067ce4f26f7f7644f757bfdf71d8f98a91b1b96246aa158f3bd780
Contents?: true
Size: 639 Bytes
Versions: 5
Compression:
Stored size: 639 Bytes
Contents
require 'spec_helper' describe TTY::Coercer::Float, '#coerce' do let(:strict) { true } subject { described_class.coerce(value, strict) } context 'with empty' do let(:value) { '' } it { expect { subject }.to raise_error(TTY::InvalidArgument) } end context 'with 1 as string' do let(:value) { '1' } it { expect(subject).to eql 1.0 } end context 'with float' do let(:value) { '1.2a' } it { expect { subject }.to raise_error(TTY::InvalidArgument) } end context 'with float not strict' do let(:value) { '1.2abc'} let(:strict) { false } it { expect(subject).to eql 1.2 } end end
Version data entries
5 entries across 5 versions & 1 rubygems