Sha256: c1970ab5937d5d7d71a23029095e0ec2e564d33214a999e485d593d1754896dc

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'test_helper'

module Vedeu

  describe Boolean do

    let(:described) { Vedeu::Boolean }
    let(:instance)  { described.new(_value) }
    let(:_value)    {}

    describe '#initialize' do
      it { instance.must_be_instance_of(Vedeu::Boolean) }
    end

    describe '.coerce' do
      subject { described.coerce(_value) }

      context 'when the value is falsy' do
        it { subject.must_equal(false) }
      end

      context 'when the value is truthy' do
        let(:_value) { 0 }

        it { subject.must_equal(true) }
      end
    end

    describe '#coerce' do
      it { instance.must_respond_to(:coerce) }
    end

    describe '#false?' do
      subject { instance.false? }

      context 'when the value is nil' do
        it { subject.must_equal(true) }
      end

      context 'when the value is false' do
        let(:_value) { false }

        it { subject.must_equal(true) }
      end

      context 'when the value is anything else' do
        let(:_value) { :anything }

        it { subject.must_equal(false) }
      end
    end

    describe '#true?' do
      subject { instance.true? }

      context 'when the value is nil' do
        it { subject.must_equal(false) }
      end

      context 'when the value is true' do
        let(:_value) { true }

        it { subject.must_equal(true) }
      end

      context 'when the value is anything else' do
        let(:_value) { :anything }

        it { subject.must_equal(true) }
      end
    end

  end # Boolean

end # Vedeu

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vedeu-0.8.32 test/lib/vedeu/boolean_test.rb
vedeu-0.8.31 test/lib/vedeu/boolean_test.rb
vedeu-0.8.30 test/lib/vedeu/boolean_test.rb
vedeu-0.8.29 test/lib/vedeu/boolean_test.rb
vedeu-0.8.28 test/lib/vedeu/boolean_test.rb
vedeu-0.8.27 test/lib/vedeu/boolean_test.rb
vedeu-0.8.26 test/lib/vedeu/boolean_test.rb
vedeu-0.8.25 test/lib/vedeu/boolean_test.rb