Skip to content

Instantly share code, notes, and snippets.

@nathenharvey
Created April 27, 2016 20:45
Show Gist options
  • Save nathenharvey/ac24b5ccabccdfc1282aca0005c05566 to your computer and use it in GitHub Desktop.
Save nathenharvey/ac24b5ccabccdfc1282aca0005c05566 to your computer and use it in GitHub Desktop.
parse_config_file fails when it encounters a '['
options = {
assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/,
comment_char: '['
}
# describe parse_config_file('/etc/yum.conf') do
describe parse_config_file('yum.conf', options) do
its('gpgcheck') { should cmp 1 }
end
options = {
assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
}
describe parse_config_file('yum.conf', options) do
its('gpgcheck') { should cmp 1 }
end
inspec exec gpgcheck.rb
F
Failures:
1) Parse Config File yum.conf gpgcheck should cmp 1
Failure/Error: DEFAULT_FAILURE_NOTIFIER = lambda { |failure, _opts| raise failure }
expected: 1
got:
(compared using `cmp` matcher)
# gpgcheck.rb:8:in `block (2 levels) in load'
# ./.chefdk/gem/ruby/2.1.0/gems/inspec-0.19.3/lib/inspec/runner_rspec.rb:67:in `run'
# ./.chefdk/gem/ruby/2.1.0/gems/inspec-0.19.3/lib/utils/base_cli.rb:70:in `run_tests'
# ./.chefdk/gem/ruby/2.1.0/gems/inspec-0.19.3/lib/inspec/cli.rb:113:in `exec'
Finished in 0.04509 seconds (files took 2.09 seconds to load)
1 example, 1 failure
Failed examples:
rspec # Parse Config File yum.conf gpgcheck should cmp 1
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
# This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment