Sha256: ce06fbc90da3ac9a81baf10c4a4c69eeecffb11c3869694e8d3e76b70a0c48d8

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true
using ObjectExtensions

RSpec.describe ObjectExtensions do
  context 'when refining Object' do
    describe '#blank?' do
      # An object is blank if it's false, empty, or a whitespace string.
      context 'for false' do
        it { expect(false.blank?).to eq(true) }
      end
      context 'for empty arrays' do
        it { expect([].blank?).to eq(true) }
      end
      context 'for empty hashes' do
        it { expect({}.blank?).to eq(true) }
      end
      context 'for whitespace string' do
        it { expect(''.blank?).to eq(true) }
      end
    end

    describe '#present?' do
      # An object is present if it's not blank.
      context 'for not blank objects' do
        it { expect(1.present?).to eq(true) }
      end

      context 'for blank objects' do
        it { expect(false.present?).to eq(false) }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finapps_core-2.0.15 spec/core_extensions/object/blank_spec.rb