You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written an rspec for an augeas resource I want to test and I'm getting an error when I try to run the test:
Failure/Error: should execute.with_change
NoMethodError:
Could not create resources for managing Puppet's files and directories in sections [:main]: undefined method `exists?' for nil:NilClass
undefined method `exists?' for nil:NilClass
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/type/user.rb:382:in `exists?'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings.rb:800:in >`service_user_available?'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings/file_setting.rb:52:in `safe_to_use_settings_value?'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings/file_setting.rb:43:in `value'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings/file_setting.rb:106:in `owner'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings/file_setting.rb:160:in `to_resource'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings.rb:916:in `block in to_catalog'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings.rb:912:in `each'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings.rb:912:in `to_catalog'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/settings.rb:982:in `use'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/util/storage.rb:45:in `load'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/resource/catalog.rb:163:in `apply'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/fixtures.rb:61:in `apply'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/resource.rb:17:in `initialize'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/example/run_augeas_example_group.rb:69:in `new'
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/rspec-puppet-augeas-0.4.0/lib/rspec-puppet-augeas/example/run_augeas_example_group.rb:69:in `subject'
# ./spec/classes/system_spec.rb:26:in `block (3 levels) in '
# ------------------
# --- Caused by: ---
# NoMethodError:
# undefined method `exists?' for nil:NilClass
# /home/jwilkicki/.rvm/gems/ruby-2.1.5/gems/puppet-3.8.3/lib/puppet/type/user.rb:382:in > `exists?'
My spec_helper looks like this:
require 'rubygems'
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-augeas'
# Create temporary config file
require 'erb'
require 'fileutils'
require 'tempfile'
require 'tmpdir'
tempdir = Dir.mktmpdir("my-spec")
parentdir = File.dirname(File.expand_path(__FILE__))
config_template = File.join(parentdir,'fixtures','puppet','puppet.conf.erb')
renderer = ERB.new(File.read(config_template))
user = Etc.getpwuid(Process.uid).name
temp_conf_name = File.join(tempdir,"puppet.conf")
temp_conf = File.open(temp_conf_name,"w+")
begin
temp_conf.puts(renderer.result(binding))
ensure
temp_conf.close
end
RSpec.configure do |c|
c.config = temp_conf_name
c.module_path = File.join(parentdir, 'fixtures', 'modules')
c.manifest_dir = File.join(parentdir, 'fixtures', 'manifests')
c.augeas_fixtures = File.join(parentdir,'fixtures','augeas')
c.after(:all) do
FileUtils.remove_entry_secure(tempdir,true)
end
end
The code with the temp file is my attempt to provide a custom puppet.conf that forces the user to be the process owner, since issue 15 seemed to indicate that Puppet might not like running as a non-root user. I've also tried without a custom puppet.conf, per the example in the README file.
My spec is pretty basic:
require 'spec_helper'
describe 'my::class' do
describe 'has augeas resource' do
it {
should contain_augeas('my attrs')
}
end
end
Puppet version is 3.8.3 and I'm using rspec 3.4.0 with rspec-puppet-augeas 0.4.0 on Ruby 2.1.5.
The text was updated successfully, but these errors were encountered:
I have written an rspec for an augeas resource I want to test and I'm getting an error when I try to run the test:
My spec_helper looks like this:
The code with the temp file is my attempt to provide a custom puppet.conf that forces the user to be the process owner, since issue 15 seemed to indicate that Puppet might not like running as a non-root user. I've also tried without a custom puppet.conf, per the example in the README file.
My spec is pretty basic:
Puppet version is 3.8.3 and I'm using rspec 3.4.0 with rspec-puppet-augeas 0.4.0 on Ruby 2.1.5.
The text was updated successfully, but these errors were encountered: