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
# /var/lib/puppet/spec/class/wrk4.wrk.cby.camptocamp.com/fail_spec.rb | |
describe 'failure' do | |
it { 2.should == 3 } | |
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
require 'catalog' | |
describe 'package' do | |
subject { Catalog.instance } | |
# subject { YAML.load_file('/tmp/catalog') } | |
it { should contain_package('augeas') } | |
it { should contain_package('augeas-lenses') } | |
it { should contain_package('augeas-tools') } | |
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
require 'serverspec' | |
require 'pathname' | |
require 'open3' | |
module ExecHelper | |
def ssh_exec(cmd, opts={}) | |
stdin, stdout, stderr = Open3.popen3(cmd) | |
{ :stdout => stdout.gets, :stderr => stderr.gets, :exit_code => $?.to_i, :exit_signal => nil } | |
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
info: Retrieving plugin | |
err: Could not retrieve catalog from remote server: Unit tests failed: | |
.FF.F | |
Failures: | |
1) puppet | |
Failure/Error: it { should contain_package('ppet') } | |
expected that the catalogue would contain Package[ppet] | |
# /var/lib/puppet/spec/class/puppet__client__base/puppet_package_spec.rb:4 |
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 'timeout' | |
require 'open-uri' | |
def cache | |
'/var/tmp/public_ip.fact.cache' | |
end | |
def can_connect? (wait_sec=2, url) | |
Timeout::timeout(wait_sec) { open(url) } | |
return true |
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 'puppet' | |
require 'puppet/type/user' | |
resource = Puppet::Type::User.new(:name => 'rpinson', :uid => '1502') | |
# resource = Puppet::Type::Exec.new(:name => '/bin/test', :unless => '/bin/true') | |
# resource = Puppet::Type::Service.new(:name => 'ssh', :ensure => 'running', :enable => 'false') | |
# Ensurable | |
if resource.provider.respond_to?(:exists?) and ! resource.provider.exists? | |
return false |
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
$ RUBYLIB=/home/rpinson/dev/serverspec/lib/ rspec --color --format d | |
ssh | |
should be installed | |
should be enabled | |
should be running | |
port 22 | |
should be listening |
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
module PuppetSpecReport | |
def status= (status) | |
@status = status | |
end | |
end | |
class Puppet::Transaction::Report::RestSpec < Puppet::Transaction::Report::Rest | |
def save(request) |
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
+-------------------------------------+ +-------------------------------------+ | |
| Client | | Server | | |
|-------------------------------------| |-------------------------------------| | |
| | | | | |
| mco spec | | Serverspec | | |
| + | | ^ | | |
| | | | | | | |
| v | | + | | |
| MCollective::Application | | RSpec::Core::Runner#run | | |
| | | | ^ | |
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 'ssh', :classes => [ 'augeas' ], :facts => { :osfamily => 'Debian' } do | |
it { should be_installed } | |
it { should be_enabled } | |
it { should be_running } | |
end | |
describe 'port 22', :classes => ['ssh'] do | |
it { should be_listening } |