Sha256: 6d84801dea880da90866e9a0d881f60bedc124819c62b84c68980b30f55ab3fc

Contents?: true

Size: 1.25 KB

Versions: 597

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'
require 'puppet/pops'

describe Puppet::Pops::LabelProvider do
  class TestLabelProvider
    include Puppet::Pops::LabelProvider
  end

  let(:labeler) { TestLabelProvider.new }

  it "prefixes words that start with a vowel with an 'an'" do
    expect(labeler.a_an('owl')).to eq('an owl')
  end

  it "prefixes words that start with a consonant with an 'a'" do
    expect(labeler.a_an('bear')).to eq('a bear')
  end

  it "prefixes non-word characters with an 'a'" do
    expect(labeler.a_an('[] expression')).to eq('a [] expression')
  end

  it "ignores a single quote leading the word" do
    expect(labeler.a_an("'owl'")).to eq("an 'owl'")
  end

  it "ignores a double quote leading the word" do
    expect(labeler.a_an('"owl"')).to eq('an "owl"')
  end

  it "capitalizes the indefinite article for a word when requested" do
    expect(labeler.a_an_uc('owl')).to eq('An owl')
  end

  it "raises an error when missing a character to work with" do
    expect {
      labeler.a_an('"')
    }.to raise_error(Puppet::DevError, /<"> does not appear to contain a word/)
  end

  it "raises an error when given an empty string" do
    expect {
      labeler.a_an('')
    }.to raise_error(Puppet::DevError, /<> does not appear to contain a word/)
  end
end

Version data entries

597 entries across 597 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/pops/label_provider_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.3.0-universal-darwin spec/unit/pops/label_provider_spec.rb
puppet-8.4.0 spec/unit/pops/label_provider_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.4.0-universal-darwin spec/unit/pops/label_provider_spec.rb
puppet-7.28.0 spec/unit/pops/label_provider_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-7.28.0-universal-darwin spec/unit/pops/label_provider_spec.rb
puppet-8.3.1 spec/unit/pops/label_provider_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-8.3.1-universal-darwin spec/unit/pops/label_provider_spec.rb
puppet-7.27.0 spec/unit/pops/label_provider_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/pops/label_provider_spec.rb
puppet-7.27.0-universal-darwin spec/unit/pops/label_provider_spec.rb