forked from redhat-openstack/openstack-puppet-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust the regular expression for facts.
Previously this was incorrectly handling facts that were of the form foo=1+1=2 due to the ='s in the actual fact contents. Fix this and add tests to try and prevent regressions.
- Loading branch information
Ashley Penney
committed
Apr 22, 2014
1 parent
6a5dee2
commit 68acb59
Showing
2 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
require 'facter/facter_dot_d' | ||
|
||
describe Facter::Util::DotD do | ||
|
||
context 'returns a simple fact' do | ||
before :each do | ||
Facter.stubs(:version).returns('1.6.1') | ||
subject.stubs(:entries).returns(['/etc/facter/facts.d/fake_fact.txt']) | ||
File.stubs(:readlines).with('/etc/facter/facts.d/fake_fact.txt').returns(['fake_fact=fake fact']) | ||
subject.create | ||
end | ||
|
||
it 'should return successfully' do | ||
Facter.fact(:fake_fact).value.should == 'fake fact' | ||
end | ||
end | ||
|
||
context 'returns a fact with equals signs' do | ||
before :each do | ||
Facter.stubs(:version).returns('1.6.1') | ||
subject.stubs(:entries).returns(['/etc/facter/facts.d/foo.txt']) | ||
File.stubs(:readlines).with('/etc/facter/facts.d/foo.txt').returns(['foo=1+1=2']) | ||
subject.create | ||
end | ||
|
||
it 'should return successfully' do | ||
Facter.fact(:foo).value.should == '1+1=2' | ||
end | ||
end | ||
end |