Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/models/resolved_fact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ def legacy?
def core?
type == :core
end

def to_s
@value.to_s
end
end
end
14 changes: 14 additions & 0 deletions spec/facter/facter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@
expect(result).to be_instance_of(Facter::ResolvedFact).and(having_attributes(value: 'Ubuntu'))
end

it 'can be interpolated' do
user_query = 'os.name'

allow(fact_manager_spy).to receive(:resolve_facts).and_return([os_fact])
allow(fact_collection_spy)
.to receive(:build_fact_collection!)
.with([os_fact])
.and_return(fact_collection_spy)
allow(fact_collection_spy).to receive(:value).with('os', 'name').and_return('Ubuntu')
# rubocop:disable Style/UnneededInterpolation
expect("#{Facter.fact(user_query)}").to eq('Ubuntu')
# rubocop:enable Style/UnneededInterpolation
end

it 'return no value' do
user_query = 'os.name'

Expand Down
11 changes: 11 additions & 0 deletions spec/facter/model/resolved_fact_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@
it 'responds to core? method with false' do
expect(resolved_fact.core?).to be(true)
end

# rubocop:disable Style/UnneededInterpolation
it 'can be interpolated' do
expect("#{resolved_fact}").to eq('fact_value')
end

it 'interpolation of nil value will be empty string' do
resolved = Facter::ResolvedFact.new('fact_name', nil)
expect("#{resolved}").to eq('')
end
# rubocop:enable Style/UnneededInterpolation
end

context 'when is an invalid type' do
Expand Down