Sha256: c38006dfdaeac591d3b6a3619573e96b0bb2c77c340620eace4ea81c523541e6

Contents?: true

Size: 1.63 KB

Versions: 340

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
require 'puppet_spec/modules'
require 'puppet_spec/files'

require 'puppet/gettext/module_translations'

describe Puppet::ModuleTranslations do
  include PuppetSpec::Files

  describe "loading translations from the module path" do
    let(:modpath) { tmpdir('modpath') }

    let(:module_a) { PuppetSpec::Modules.create(
      "mod_a",
      modpath,
      :metadata => {
        :author => 'foo'
      },
      :environment => double("environment"))
    }

    let(:module_b) { PuppetSpec::Modules.create(
      "mod_b",
      modpath,
      :metadata => {
        :author => 'foo'
      },
      :environment => double("environment"))
    }

    it "should attempt to load translations only for modules that have them" do
      expect(module_a).to receive(:has_translations?).and_return(false)
      expect(module_b).to receive(:has_translations?).and_return(true)
      expect(Puppet::GettextConfig).to receive(:load_translations).with("foo-mod_b", File.join(modpath, "mod_b", "locales"), :po).and_return(true)

      Puppet::ModuleTranslations.load_from_modulepath([module_a, module_b])
    end
  end

  describe "loading translations from $vardir" do
    let(:vardir) {
      dir_containing("vardir",
        { "locales" => { "ja" => { "foo-mod_a.po" => "" } } })
    }

    it "should attempt to load translations for the current locale" do
      expect(Puppet::GettextConfig).to receive(:current_locale).and_return("ja")
      expect(Puppet::GettextConfig).to receive(:load_translations).with("foo-mod_a", File.join(vardir, "locales"), :po).and_return(true)

      Puppet::ModuleTranslations.load_from_vardir(vardir)
    end
  end
end

Version data entries

340 entries across 340 versions & 1 rubygems

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