@@ -178,6 +178,62 @@ def context_double(options = {})
178178 end
179179end
180180
181+ describe RSpec ::Puppet ::Adapters ::Adapter6X , :if => ( 6.0 ... 6.25 ) . include? ( Puppet . version . to_f ) do
182+
183+ let ( :test_context ) { double :environment => 'rp_env' }
184+
185+ describe '#setup_puppet' do
186+ describe 'when managing the facter_implementation' do
187+ after ( :each ) do
188+ Object . send ( :remove_const , :FacterImpl ) if defined? FacterImpl
189+ end
190+
191+ it 'warns and falls back if hash implementation is set and facter runtime is not supported' do
192+ context = context_double
193+ allow ( RSpec . configuration ) . to receive ( :facter_implementation ) . and_return ( 'rspec' )
194+ expect ( subject ) . to receive ( :warn )
195+ . with ( "Facter runtime implementations are not supported in Puppet #{ Puppet . version } , continuing with facter_implementation 'facter'" )
196+ subject . setup_puppet ( context )
197+ expect ( FacterImpl ) . to be ( Facter )
198+ end
199+ end
200+ end
201+ end
202+
203+ describe RSpec ::Puppet ::Adapters ::Adapter6X , :if => Puppet ::Util ::Package . versioncmp ( Puppet . version , '6.25.0' ) >= 0 do
204+
205+ let ( :test_context ) { double :environment => 'rp_env' }
206+
207+ describe '#setup_puppet' do
208+ describe 'when managing the facter_implementation' do
209+ after ( :each ) do
210+ Object . send ( :remove_const , :FacterImpl ) if defined? FacterImpl
211+ end
212+
213+ it 'uses facter as default implementation' do
214+ context = context_double
215+ subject . setup_puppet ( context )
216+ expect ( FacterImpl ) . to be ( Facter )
217+ end
218+
219+ it 'uses the hash implementation if set and if puppet supports runtimes' do
220+ context = context_double
221+ Puppet . runtime [ :facter ] = 'something'
222+ allow ( RSpec . configuration ) . to receive ( :facter_implementation ) . and_return ( 'rspec' )
223+ subject . setup_puppet ( context )
224+ expect ( FacterImpl ) . to be_kind_of ( RSpec ::Puppet ::FacterTestImpl )
225+ end
226+
227+ it 'raises if given an unsupported option' do
228+ context = context_double
229+ allow ( RSpec . configuration ) . to receive ( :facter_implementation ) . and_return ( 'salam' )
230+ expect { subject . setup_puppet ( context ) }
231+ . to raise_error ( RuntimeError , "Unsupported facter_implementation 'salam'" )
232+ end
233+ end
234+ end
235+ end
236+
181237describe RSpec ::Puppet ::Adapters ::Adapter4X , :if => ( 4.0 ... 6.0 ) . include? ( Puppet . version . to_f ) do
182238
183239 let ( :test_context ) { double :environment => 'rp_env' }
0 commit comments