spec/shared/context.rb in beaker-answers-0.16.0 vs spec/shared/context.rb in beaker-answers-0.17.0

- old
+ new

@@ -129,19 +129,18 @@ expect { answers.answers }.to raise_error(TypeError, /q_ answers are not supported/) end end end +end + +RSpec.shared_examples "overriding answers" do context 'when overriding answers' do let( :options ) do { :format => 'hiera', - :answers => { - 'puppet_enterprise' => { 'certificate_authority_host' => 'enterpriseca.vm' }, - 'puppet_enterprise::console_host' => 'enterpriseconsole.vm', - 'console_admin_password' => 'testing123', - } + :answers => answers_with_strings, } end it 'matches expected answers' do expect(answer_hash).to match(gold_answers_with_overrides) @@ -150,27 +149,54 @@ context 'when overriding answers using symbolic keys' do let( :options ) do { :format => 'hiera', - :answers => { - :puppet_enterprise => { - :certificate_authority_host => 'enterpriseca.vm', - :console_host => 'enterpriseconsole.vm', - }, - :console_admin_password => 'testing123', - } + :answers => answers_with_symbols, } end it 'matches expected answers' do expect(answer_hash).to match(gold_answers_with_overrides) end end end RSpec.shared_examples "valid MEEP 2.0 pe.conf" do + let(:answers_with_symbols) do + { + :"puppet_enterprise::certificate_authority_host" => 'enterpriseca.vm', + :"puppet_enterprise::console_host" => 'enterpriseconsole.vm', + :console_admin_password => 'testing123', + :feature_flags => { + 'pe_modules_next' => true, + }, + } + end + let(:answers_with_strings) do + { + 'puppet_enterprise::certificate_authority_host' => 'enterpriseca.vm', + 'puppet_enterprise::console_host' => 'enterpriseconsole.vm', + 'console_admin_password' => 'testing123', + 'feature_flags' => { + 'pe_modules_next' => true, + }, + } + end + let( :overridding_parameters ) do + { + 'puppet_enterprise::certificate_authority_host' => 'enterpriseca.vm', + 'puppet_enterprise::console_host' => 'enterpriseconsole.vm', + 'console_admin_password' => 'testing123', + 'feature_flags' => { + 'pe_modules_next' => true, + } + } + end + + include_examples "overriding answers" + it 'generates valid MEEP 2.0 json if #answer_hiera is called' do expect(answer_hiera).not_to be_empty expect { JSON.load(answer_hiera) }.not_to raise_error expect(answer_hiera).to match(%r{"node_roles"\s*:\s*\{}) expect(answer_hiera).to match(%r{"pe_role::\w+::primary_master"\s*:\s*\[\s*"#{hosts[0].hostname}"\s*\]}m) @@ -194,9 +220,28 @@ end end end RSpec.shared_examples "valid MEEP 1.0 pe.conf" do + let(:answers_with_symbols) do + { + :puppet_enterprise => { + :certificate_authority_host => 'enterpriseca.vm', + :console_host => 'enterpriseconsole.vm', + }, + :console_admin_password => 'testing123', + } + end + let(:answers_with_strings) do + { + 'puppet_enterprise' => { 'certificate_authority_host' => 'enterpriseca.vm' }, + 'puppet_enterprise::console_host' => 'enterpriseconsole.vm', + 'console_admin_password' => 'testing123', + } + end + + include_examples "overriding answers" + it 'generates valid MEEP 1.0 json if #answer_hiera is called' do expect(answer_hiera).not_to be_empty expect { JSON.load(answer_hiera) }.not_to raise_error expect(answer_hiera).to match(%r{"puppet_enterprise::puppet_master_host"\s*:\s*"#{hosts[0].hostname}"}m) end