Skip to content

A gem that provides a hiera backend for setting up hiera data in unit tests

License

Notifications You must be signed in to change notification settings

otto-de-legacy/hiera-backend-rspec

Repository files navigation

hiera-backend-rspec

Gem Version travis-ci Code Climate Test Coverage

This gem provides a hiera backend for setting up hiera data in tests. At the time if this writing, hiera-backend-rspec is meant to interface with Hiera version 3.2.0.

Installation

Add this line to your application's Gemfile:

gem 'hiera-backend-rspec'

And then run:

$ bundle install

Alternatively, if you wish to just use the gem in a script, you can run:

$ gem install hiera-backend-rspec

Finally, just add require 'hiera-backend-rspec' to the top of the file using this gem.

Usage

Put this into your spec_helper.rb:

RSpec.configure do |c|
  c.before(:each) do
    Thread.current[:rspec_hiera_data] = hiera_data if respond_to?(:hiera_data)
  end
    
  c.after(:each) do
    Thread.current[:rspec_hiera_data] = nil
  end
end

In your specs you can now set up simple hiera data.

let(:hiera_data) do
  {
      'hiera::key' => 'value'
  }
end

Contributing

Please fork and send pull request. Make sure to have test cases for your changes.

License

This program is licensed under the MIT license. See LICENSE for details.

About

A gem that provides a hiera backend for setting up hiera data in unit tests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •