Sha256: 5142475546e9cdb756a4400954f3b2809aeb6631ce9aef417ce87177594bcedd

Contents?: true

Size: 1.36 KB

Versions: 54

Compression:

Stored size: 1.36 KB

Contents

# Manage whether a test is runnable.
module PuppetTest
  module RunnableTest
    # Confine this example group based on specified criteria.  This can be
    # a message and its related test either as a hash or as a single
    # message argument and a block to be evaluated at the time the confine
    # is checked.
    #
    # Examples:
    #
    # confine "Rails is not available" => Puppet.features.rails?
    #
    # confine("ActiveRecord 2.1.x") { ::ActiveRecord::VERSION::MAJOR == 2 and ::ActiveRecord::VERSION::MINOR <= 1 }
    #
    def confine(hash_or_message, &block)
      hash = block_given? ? {hash_or_message => block} : hash_or_message
      confines.update hash
    end

    # Check all confines for a given example group, starting with any
    # specified in the parent example group. If any confine test is false,
    # the example group is not runnable (and will be skipped). Note: This
    # is used directly by Rspec and is not intended for develper use.
    #
    def runnable?
      return false if superclass.respond_to?(:runnable?) and not superclass.runnable?

      confines.each do |message, is_runnable|
        is_runnable = is_runnable.call if is_runnable.respond_to?(:call)
        messages << message unless is_runnable
      end

      messages.empty?
    end

    def messages; @messages ||= [] end

    private

    def confines; @confines ||= {} end
  end

end

Version data entries

54 entries across 54 versions & 3 rubygems

Version Path
puppet-2.7.26 test/lib/puppettest/runnable_test.rb
puppet-2.7.25 test/lib/puppettest/runnable_test.rb
puppet-2.7.24 test/lib/puppettest/runnable_test.rb
puppet-2.7.23 test/lib/puppettest/runnable_test.rb
puppet-2.7.22 test/lib/puppettest/runnable_test.rb
puppet-2.7.21 test/lib/puppettest/runnable_test.rb
puppet-2.6.18 test/lib/puppettest/runnable_test.rb
puppet-2.7.20 test/lib/puppettest/runnable_test.rb
puppet-2.7.20.rc1 test/lib/puppettest/runnable_test.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/lib/puppettest/runnable_test.rb
puppet-2.7.19 test/lib/puppettest/runnable_test.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/runnable_test.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/lib/puppettest/runnable_test.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/runnable_test.rb
puppet-2.7.18 test/lib/puppettest/runnable_test.rb
puppet-2.6.17 test/lib/puppettest/runnable_test.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/runnable_test.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/lib/puppettest/runnable_test.rb
puppet-2.7.17 test/lib/puppettest/runnable_test.rb
puppet-2.7.16 test/lib/puppettest/runnable_test.rb