Sha256: ff800c2094f51146799cc2b5728f50bbcb57fa002c14f281c1baf76663c217ab
Contents?: true
Size: 1.22 KB
Versions: 12
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true RSpec.describe ObjectExtensions do context 'when refining Object' do using ObjectExtensions 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 describe '#presence' do # Returns the receiver if it's present otherwise returns +nil+. context 'returns the receiver when the receiver is present' do it { expect(true.presence).to eq(true) } end context 'returns nil when the receiver is not present' do it { expect(false.presence).to be_nil } end end end end
Version data entries
12 entries across 12 versions & 1 rubygems