Sha256: b9b994b49ac0ec87437f5f0fab44244ba1f47c531abe9f2e84f6285c384eeb36
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' RSpec.describe Onebox::Helpers do describe '.blank?' do it { expect(described_class.blank?("")).to be(true) } it { expect(described_class.blank?(" ")).to be(true) } it { expect(described_class.blank?("test")).to be(false) } it { expect(described_class.blank?(["test", "testing"])).to be(false) } it { expect(described_class.blank?([])).to be(true) } it { expect(described_class.blank?({})).to be(true) } it { expect(described_class.blank?({a: 'test'})).to be(false) } it { expect(described_class.blank?(nil)).to be(true) } it { expect(described_class.blank?(true)).to be(false) } it { expect(described_class.blank?(false)).to be(true) } end describe ".truncate" do let(:test_string) { "Chops off on spaces" } it { expect(described_class.truncate(test_string)).to eq(test_string) } it { expect(described_class.truncate(test_string,5)).to eq("Chops...") } it { expect(described_class.truncate(test_string,7)).to eq("Chops...") } it { expect(described_class.truncate(test_string,9)).to eq("Chops off...") } it { expect(described_class.truncate(test_string,10)).to eq("Chops off...") } it { expect(described_class.truncate(test_string,100)).to eq("Chops off on spaces") } it { expect(described_class.truncate(" #{test_string} ",6)).to eq(" Chops...") } end end
Version data entries
10 entries across 10 versions & 1 rubygems