Merge pull request #862 from puppetlabs/pdksync_pdksync_heads/master-0-g7827fc2
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / locales_spec.rb
1 require 'spec_helper_acceptance'
2 require 'beaker/i18n_helper'
3
4 PUPPETLABS_GPG_KEY_LONG_ID     = '7F438280EF8D349F'.freeze
5 PUPPETLABS_LONG_FINGERPRINT    = '123456781274D2C8A956789A456789A456789A9A'.freeze
6
7 id_doesnt_match_fingerprint_pp = <<-MANIFEST
8   apt_key { '#{PUPPETLABS_LONG_FINGERPRINT}':
9     ensure  => 'present',
10     content => '123456781274D2C8A956789A456789A456789A9B',
11   }
12 MANIFEST
13
14 location_not_specified_fail_pp = <<-MANIFEST
15   apt::source { 'puppetlabs':
16     ensure  => 'present',
17     repos   => 'main',
18     key     => {
19       id      => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
20       server  => 'hkps.pool.sks-keyservers.net',
21     },
22   }
23 MANIFEST
24
25 invalid_title_pp = <<-MANIFEST
26   apt::setting { 'test':
27     ensure  => 'present',
28     content => 'test'
29   }
30 MANIFEST
31
32 no_content_param_pp = <<-MANIFEST
33   apt::conf { 'test':
34     ensure => 'present',
35   }
36 MANIFEST
37
38 describe 'localization', if: (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (Gem::Version.new(puppet_version) >= Gem::Version.new('4.10.5')) do
39   before :all do
40     hosts.each do |host|
41       on(host, "sed -i \"96i FastGettext.locale='ja'\" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb")
42       change_locale_on(host, 'ja_JP.utf-8')
43     end
44   end
45
46   describe 'ruby translations' do
47     it 'translates an interpolated string' do
48       apply_manifest(id_doesnt_match_fingerprint_pp, expect_failures: true) do |r|
49         expect(r.stderr).to match(%r{content/sourceが正当であるかを確認してください})
50       end
51     end
52     it 'translates a simple string' do
53       apply_manifest(location_not_specified_fail_pp, expect_failures: true) do |r|
54         expect(r.stderr).to match(%r{場所を指定せずにソースエントリを作成することはできません})
55       end
56     end
57   end
58
59   describe 'puppet translations' do
60     it 'translates a concatenated string' do
61       apply_manifest(invalid_title_pp, expect_failures: true) do |r|
62         expect(r.stderr).to match(%r{apt::settingのリソース名/タイトルの先頭は、'conf-'、'pref-'、'list-'にする必要があります})
63       end
64     end
65     it 'translates a simple string' do
66       apply_manifest(no_content_param_pp, expect_failures: true) do |r|
67         expect(r.stderr).to match(%r{contentパラメータを渡す必要があります})
68       end
69     end
70   end
71
72   after :all do
73     hosts.each do |host|
74       on(host, 'sed -i "96d" /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb')
75       change_locale_on(host, 'en_US')
76     end
77   end
78 end