Last active
December 20, 2015 15:28
-
-
Save thejoecarroll/6153949 to your computer and use it in GitHub Desktop.
RSpec-testing a simple Puppet module (MOTD).
This file contains hidden or 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
. | |
├── Modulefile | |
├── README | |
├── Rakefile | |
├── files | |
│ └── README.markdown | |
├── lib | |
│ └── puppet | |
│ ├── facter | |
│ │ └── README.markdown | |
│ ├── parser | |
│ │ └── functions | |
│ │ └── README.markdown | |
│ ├── provider | |
│ │ └── README.markdown | |
│ └── type | |
│ └── README.markdown | |
├── manifests | |
│ ├── README.markdown | |
│ └── init.pp | |
├── metadata.json | |
├── spec | |
│ ├── README.markdown | |
│ ├── classes | |
│ │ ├── README.markdown | |
│ │ └── motd_spec.rb | |
│ ├── defines | |
│ │ └── README.markdown | |
│ ├── fixtures | |
│ │ ├── manifests | |
│ │ │ └── site.pp | |
│ │ └── modules | |
│ │ └── motd -> /Volumes/MacHD/Data/joecarroll/src/Sihti/macs-puppet/puppet/modules/motd | |
│ ├── functions | |
│ │ └── README.markdown | |
│ ├── hosts | |
│ │ └── README.markdown | |
│ ├── spec.opts | |
│ ├── spec_helper.rb | |
│ └── unit | |
│ └── puppet | |
│ ├── provider | |
│ │ └── README.markdown | |
│ └── type | |
│ └── README.markdown | |
├── templates | |
│ ├── README.markdown | |
│ └── motd.erb | |
└── tests | |
└── init.pp | |
24 directories, 25 files |
This file contains hidden or 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
include motd |
This file contains hidden or 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
name 'puppetlabs-motd' | |
version '1.0.1' | |
source 'git@github.com:puppetlabs/puppetlabs-motd.git' | |
author 'puppetlabs' | |
license 'Apache License, Version 2.0' | |
summary 'A simple module to demonstrate managing /etc/motd as a template' | |
description 'This module simply manages /etc/motd as a template, showing interpolation of system attributes' | |
project_page 'https://github.com/puppetlabs/puppetlabs-motd' |
This file contains hidden or 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 Sihti Mac is managed with Puppet v<%= @puppetversion %>. | |
Contact: itadmin@sihti.fi | |
Your FQDN is <%= @fqdn %> | |
Uptime: <%= @sp_uptime %> |
This file contains hidden or 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 "spec_helper" | |
describe 'motd', :type => 'class' do | |
context "Message Of The Day" do | |
let :facts do | |
{ | |
:@puppetversion => '3.0.0' | |
} | |
end | |
it { | |
should contain_file('/etc/motd').with({ | |
'ensure' => 'present', | |
'owner' => 'root', | |
'group' => 'wheel', | |
'mode' => '0644' | |
}).with_content(/^.+Puppet v3\.0\.0$/) | |
} | |
end | |
end |
This file contains hidden or 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
$ rake spec_clean spec_prep; rspec --colour --backtrace | |
F | |
Failures: | |
1) motd Message Of The Day should contain File[/etc/motd] with group => "wheel", mode => "0644", ensure => "present", owner => "root" and content matching /^.+Puppet v3\.0\.0$/ | |
Failure/Error: }).with_content(/^.+Puppet v3\.0\.0$/) | |
expected that the catalogue would contain File[/etc/motd] | |
# /Library/Ruby/Gems/1.8/gems/rspec-expectations-2.14.0/lib/rspec/expectations/fail_with.rb:32:in `fail_with' | |
# /Library/Ruby/Gems/1.8/gems/rspec-expectations-2.14.0/lib/rspec/expectations/handler.rb:36:in `handle_matcher' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/memoized_helpers.rb:68:in `should' | |
# ./spec/classes/motd_spec.rb:16 | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `instance_eval' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:114:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:254:in `with_around_each_hooks' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example.rb:111:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:400:in `run_examples' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `map' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:396:in `run_examples' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:381:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `map' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/example_group.rb:382:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `map' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:28:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/reporter.rb:58:in `report' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/command_line.rb:25:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:80:in `run' | |
# /Library/Ruby/Gems/1.8/gems/rspec-core-2.14.4/lib/rspec/core/runner.rb:17:in `autorun' | |
# /usr/bin/rspec:23 | |
Finished in 0.39232 seconds | |
1 example, 1 failure | |
Failed examples: | |
rspec ./spec/classes/motd_spec.rb:10 # motd Message Of The Day should contain File[/etc/motd] with group => "wheel", mode => "0644", ensure => "present", owner => "root" and content matching /^.+Puppet v3\.0\.0$/ |
This file contains hidden or 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 'rubygems' | |
require 'puppetlabs_spec_helper/module_spec_helper' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment