dev/provisioning/modules/stdlib/spec/spec_helper.rb
changeset 28 b0b56e0f8c7f
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
       
     1 #! /usr/bin/env ruby -S rspec
       
     2 dir = File.expand_path(File.dirname(__FILE__))
       
     3 $LOAD_PATH.unshift File.join(dir, 'lib')
       
     4 
       
     5 # So everyone else doesn't have to include this base constant.
       
     6 module PuppetSpec
       
     7   FIXTURE_DIR = File.join(dir = File.expand_path(File.dirname(__FILE__)), "fixtures") unless defined?(FIXTURE_DIR)
       
     8 end
       
     9 
       
    10 require 'puppet'
       
    11 require 'rspec-puppet'
       
    12 require 'puppetlabs_spec_helper/module_spec_helper'
       
    13 require 'monkey_patches/alias_should_to_must'
       
    14 require 'mocha/api'
       
    15 #require 'puppetlabs_spec_helper/module_spec_helper'
       
    16 require 'puppetlabs_spec_helper_clone'
       
    17 
       
    18 # hack to enable all the expect syntax (like allow_any_instance_of) in rspec-puppet examples
       
    19 RSpec::Mocks::Syntax.enable_expect(RSpec::Puppet::ManifestMatchers)
       
    20 
       
    21 RSpec.configure do |config|
       
    22   config.module_path = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'modules')
       
    23   config.manifest_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'manifests')
       
    24   config.environmentpath = spec_path = File.expand_path(File.join(Dir.pwd, 'spec'))
       
    25 
       
    26   config.add_setting :puppet_future
       
    27   #config.puppet_future = (ENV['FUTURE_PARSER'] == 'yes' or Puppet.version.to_f >= 4.0)
       
    28   config.puppet_future = Puppet.version.to_f >= 4.0
       
    29 
       
    30   config.before :each do
       
    31     # Ensure that we don't accidentally cache facts and environment between
       
    32     # test cases.  This requires each example group to explicitly load the
       
    33     # facts being exercised with something like
       
    34     # Facter.collection.loader.load(:ipaddress)
       
    35     Facter.clear
       
    36     Facter.clear_messages
       
    37 
       
    38     RSpec::Mocks.setup
       
    39   end
       
    40 
       
    41   config.after :each do
       
    42     RSpec::Mocks.verify
       
    43     RSpec::Mocks.teardown
       
    44   end
       
    45 end
       
    46 
       
    47 # Helper class to test handling of arguments which are derived from string
       
    48 class AlsoString < String
       
    49 end