|  | 
| 51 | 51 |   # Continue gracefully | 
| 52 | 52 | end | 
| 53 | 53 | 
 | 
| 54 |  | -# This is just a utility class to allow us to isolate the various version-specific | 
| 55 |  | -# branches of initialization logic into methods without polluting the global namespace.# | 
| 56 |  | -class Puppet::PuppetSpecInitializer | 
| 57 |  | -  # This method is for initializing puppet state for testing for older versions | 
| 58 |  | -  # of puppet that do not support the new TestHelper API.  As you can see, | 
| 59 |  | -  # this involves explicitly modifying global variables, directly manipulating | 
| 60 |  | -  # Puppet's Settings singleton object, and other fun implementation details | 
| 61 |  | -  # that code external to puppet should really never know about. | 
| 62 |  | -  def self.initialize_via_fallback_compatibility(config) | 
| 63 |  | -    warn('Warning: you appear to be using an older version of puppet; spec_helper will use fallback compatibility mode.') | 
| 64 |  | -    config.before :all do | 
| 65 |  | -      # nothing to do for now | 
| 66 |  | -    end | 
| 67 |  | - | 
| 68 |  | -    config.after :all do | 
| 69 |  | -      # nothing to do for now | 
| 70 |  | -    end | 
| 71 |  | - | 
| 72 |  | -    config.before :each do | 
| 73 |  | -      # these globals are set by Application | 
| 74 |  | -      $puppet_application_mode = nil # rubocop:disable Style/GlobalVars | 
| 75 |  | -      $puppet_application_name = nil # rubocop:disable Style/GlobalVars | 
| 76 |  | - | 
| 77 |  | -      # REVISIT: I think this conceals other bad tests, but I don't have time to | 
| 78 |  | -      # fully diagnose those right now.  When you read this, please come tell me | 
| 79 |  | -      # I suck for letting this float. --daniel 2011-04-21 | 
| 80 |  | -      Signal.stubs(:trap) | 
| 81 |  | - | 
| 82 |  | -      # Set the confdir and vardir to gibberish so that tests | 
| 83 |  | -      # have to be correctly mocked. | 
| 84 |  | -      Puppet[:confdir] = '/dev/null' | 
| 85 |  | -      Puppet[:vardir] = '/dev/null' | 
| 86 |  | - | 
| 87 |  | -      # Avoid opening ports to the outside world | 
| 88 |  | -      Puppet.settings[:bindaddress] = '127.0.0.1' | 
| 89 |  | -    end | 
| 90 |  | - | 
| 91 |  | -    config.after :each do | 
| 92 |  | -      Puppet.settings.clear | 
| 93 |  | - | 
| 94 |  | -      Puppet::Node::Environment.clear | 
| 95 |  | -      Puppet::Util::Storage.clear | 
| 96 |  | -      Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? 'ExecutionStub' | 
| 97 |  | - | 
| 98 |  | -      PuppetlabsSpec::Files.cleanup | 
| 99 |  | -    end | 
| 100 |  | -  end | 
| 101 |  | -end | 
| 102 |  | - | 
| 103 |  | -# JJM Hack to make the stdlib tests run in Puppet 2.6 (See puppet commit cf183534) | 
| 104 |  | -unless Puppet.constants.include? 'Test' | 
| 105 |  | -  module Puppet::Test | 
| 106 |  | -    # This is a stub class to allow the stdlib tests to run in Puppet 2.6 | 
| 107 |  | -    # This class will be removed in another commit. | 
| 108 |  | -    class LogCollector | 
| 109 |  | -      def initialize(logs) | 
| 110 |  | -        @logs = logs | 
| 111 |  | -      end | 
| 112 |  | - | 
| 113 |  | -      def <<(value) | 
| 114 |  | -        @logs << value | 
| 115 |  | -      end | 
| 116 |  | -    end | 
| 117 |  | -  end | 
| 118 |  | -  Puppet::Util::Log.newdesttype :log_collector do | 
| 119 |  | -    match 'Puppet::Test::LogCollector' | 
| 120 |  | - | 
| 121 |  | -    def initialize(messages) | 
| 122 |  | -      @messages = messages | 
| 123 |  | -    end | 
| 124 |  | - | 
| 125 |  | -    def handle(msg) | 
| 126 |  | -      @messages << msg | 
| 127 |  | -    end | 
| 128 |  | -  end | 
| 129 |  | -end | 
| 130 |  | - | 
| 131 | 54 | # And here is where we do the main rspec configuration / setup. | 
| 132 | 55 | RSpec.configure do |config| | 
| 133 | 56 |   # Detect whether the module is overriding the choice of mocking framework | 
|  | 
0 commit comments