This repository was archived by the owner on Jun 19, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,5 +22,9 @@ def legacy?
2222 def core?
2323 type == :core
2424 end
25+
26+ def to_s
27+ @value . to_s
28+ end
2529 end
2630end
Original file line number Diff line number Diff line change 166166 expect ( result ) . to be_instance_of ( Facter ::ResolvedFact ) . and ( having_attributes ( value : 'Ubuntu' ) )
167167 end
168168
169+ it 'can be interpolated' do
170+ user_query = 'os.name'
171+
172+ allow ( fact_manager_spy ) . to receive ( :resolve_facts ) . and_return ( [ os_fact ] )
173+ allow ( fact_collection_spy )
174+ . to receive ( :build_fact_collection! )
175+ . with ( [ os_fact ] )
176+ . and_return ( fact_collection_spy )
177+ allow ( fact_collection_spy ) . to receive ( :value ) . with ( 'os' , 'name' ) . and_return ( 'Ubuntu' )
178+ # rubocop:disable Style/UnneededInterpolation
179+ expect ( "#{ Facter . fact ( user_query ) } " ) . to eq ( 'Ubuntu' )
180+ # rubocop:enable Style/UnneededInterpolation
181+ end
182+
169183 it 'return no value' do
170184 user_query = 'os.name'
171185
Original file line number Diff line number Diff line change 2323 it 'responds to core? method with false' do
2424 expect ( resolved_fact . core? ) . to be ( true )
2525 end
26+
27+ # rubocop:disable Style/UnneededInterpolation
28+ it 'can be interpolated' do
29+ expect ( "#{ resolved_fact } " ) . to eq ( 'fact_value' )
30+ end
31+
32+ it 'interpolation of nil value will be empty string' do
33+ resolved = Facter ::ResolvedFact . new ( 'fact_name' , nil )
34+ expect ( "#{ resolved } " ) . to eq ( '' )
35+ end
36+ # rubocop:enable Style/UnneededInterpolation
2637 end
2738
2839 context 'when is an invalid type' do
You can’t perform that action at this time.
0 commit comments