Sha256: e6600cf5c4c41ab9542b8054775aa45c4175b569aff9d0a9ba338558ef88de73

Contents?: true

Size: 766 Bytes

Versions: 2

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe String do
  describe '#permalink!' do
    let(:string) { 'foo bar'.dup }

    before { string.permalink! }

    it { expect(string).to eq 'foo-bar' }
  end

  describe '#to_bool' do
    subject { string.to_bool }

    describe 'true values' do
      %w[true t yes y 1].each do |val|
        let(:string) { val }
        it { is_expected.to eq true }
      end
    end

    describe 'false values' do
      (%w[false f no n 0] + ['']).each do |val|
        let(:string) { val }
        it { is_expected.to eq false }
      end
    end

    describe 'no truthy or falsy' do
      let(:string) { 'foo' }
      it { expect { subject }.to raise_error(%(invalid value for Boolean: "foo")) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locomotivecms_common-0.6.0.alpha1 spec/unit/core_ext/string_spec.rb
locomotivecms_common-0.5.0 spec/unit/core_ext/string_spec.rb