Sha256: d63a3683f28da722035b143268abac87c82d48c40b451d0714267ac3518cae2d
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require 'bigdecimal' describe WannabeBool::Numeric do context Integer do describe '#to_b' do context 'when value is 0' do subject { 0 } it { expect(subject.to_b).to be false } end context 'positive values' do (1..9).each do |value| context "when value is #{value}" do subject { value } it { expect(subject.to_b).to be true } end end end context 'negative values' do (-9..-1).each do |value| context "when value is #{value}" do subject { value } it { expect(subject.to_b).to be true } end end end end end context Float do describe '#to_b' do context 'when value is 0.0' do subject { 0.0 } it { expect(subject.to_b).to be false } end context "when value is positive" do subject { Random.rand } it { expect(subject.to_b).to be true } end context "when value is negative" do subject { Random.rand * -1 } it { expect(subject.to_b).to be true } end end end context BigDecimal do describe '#to_b' do context 'when value is 0.0' do subject { BigDecimal('0.0') } it { expect(subject.to_b).to be false } end context "when value is positive" do subject { BigDecimal('1.0') } it { expect(subject.to_b).to be true } end context "when value is negative" do subject { BigDecimal('-1.0') } it { expect(subject.to_b).to be true } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wannabe_bool-0.5.0 | spec/wannabe_bool/numeric_spec.rb |
wannabe_bool-0.4.0 | spec/wannabe_bool/numeric_spec.rb |