Created
September 4, 2011 12:04
-
-
Save nistude/1192764 to your computer and use it in GitHub Desktop.
Storeconfigs setup for cucumber-puppet
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
Feature: storeconfigs | |
Scenario: export resource | |
Given a node of class "exporting" | |
When I compile its catalog | |
Then it should export a resource "File[foo]" | |
Scenario: collect resource | |
Given a node of class "collecting" | |
And an exported resource "File[bar]" | |
When I compile its catalog | |
Then there should be a resource "File[bar]" |
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
class exporting { | |
@@file { "foo": } | |
} | |
class collecting { | |
File <<||>> | |
} |
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
Given /^an exported resource "([^"]*)"$/ do |res| | |
fail("#{res} does not denote a resource") unless res =~ /^([A-Z][a-z]+)\[(.*)\]$/ | |
restype = $1 | |
title = $2 | |
Puppet::Rails::Resource.create!( | |
:exported => true, | |
# needs to differ between exporting and collecting host, afaik | |
# current host should get host_id 1 | |
:host_id => 2, | |
:restype => restype, | |
:title => title | |
) | |
end | |
Then /^it should export a resource "([^"]*)"$/ do |res| | |
found = false | |
Puppet::Rails::Resource.all.each do |r| | |
if r.name == res | |
found = true | |
break | |
end | |
end | |
fail "#{res} not found in exported resources" unless found | |
end |
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
require 'active_record' | |
require 'database_cleaner' | |
require 'tmpdir' | |
DatabaseCleaner.strategy = :truncation | |
# puppet will want to create some directories with storeconfigs | |
@@vardir = Dir.mktmpdir | |
Before do | |
@puppetcfg['confdir'] = File.join(File.dirname(__FILE__), '..', '..') | |
@puppetcfg['manifest'] = File.join(@puppetcfg['confdir'], 'site.pp') | |
# for storeconfigs | |
@puppetcfg['vardir'] = @@vardir | |
@puppetcfg['storeconfigs'] = true | |
@puppetcfg['thin_storeconfigs'] = true | |
@puppetcfg['dblocation'] = ':memory:' | |
end | |
After do | |
# cleanup database after each scenario | |
DatabaseCleaner.clean | |
end | |
at_exit do | |
# cleanup temporary vardir after cucumber-puppet run | |
FileUtils.remove_entry_secure @@vardir | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment