Sha256: 23fca00ab4806664e4580fab45e3218ee6019a885df6f14d138e8750d7595e41

Contents?: true

Size: 1.41 KB

Versions: 19

Compression:

Stored size: 1.41 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../spec_helper'

require 'puppet/parser/collector'

describe Puppet::Parser::Collector do
  before do
    @scope = Puppet::Parser::Scope.new(:compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode")))

    @resource = Puppet::Parser::Resource.new("file", "/tmp/testing", :scope => @scope, :source => "fakesource")
    {:owner => "root", :group => "bin", :mode => "644"}.each do |param, value|
      @resource[param] = value
    end
  end

  def query(text)
    code = "File <| #{text} |>"
    parser = Puppet::Parser::Parser.new(@scope.compiler)
    parser.parse(code).hostclass("").code[0].query
  end

  {true => [%{title == "/tmp/testing"}, %{(title == "/tmp/testing")}, %{group == bin},
    %{title == "/tmp/testing" and group == bin}, %{title == bin or group == bin},
    %{title == "/tmp/testing" or title == bin}, %{title == "/tmp/testing"},
    %{(title == "/tmp/testing" or title == bin) and group == bin}],
  false => [%{title == bin}, %{title == bin or (title == bin and group == bin)},
    %{title != "/tmp/testing"}, %{title != "/tmp/testing" and group != bin}]
  }.each do |result, ary|
    ary.each do |string|
      it "should return '#{result}' when collecting resources with '#{string}'" do
        str, code = query(string).evaluate @scope
        code.should be_instance_of(Proc)
        code.call(@resource).should == result
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/integration/parser/collector_spec.rb
puppet-2.6.17 spec/integration/parser/collector_spec.rb
puppet-2.6.16 spec/integration/parser/collector_spec.rb
puppet-2.6.15 spec/integration/parser/collector_spec.rb
puppet-2.6.14 spec/integration/parser/collector_spec.rb
puppet-2.6.13 spec/integration/parser/collector_spec.rb
puppet-2.6.12 spec/integration/parser/collector_spec.rb
puppet-2.6.11 spec/integration/parser/collector_spec.rb
puppet-2.6.10 spec/integration/parser/collector_spec.rb
puppet-2.6.9 spec/integration/parser/collector_spec.rb
puppet-2.6.8 spec/integration/parser/collector_spec.rb
puppet-2.6.7 spec/integration/parser/collector_spec.rb
puppet-2.6.6 spec/integration/parser/collector_spec.rb
puppet-2.6.5 spec/integration/parser/collector_spec.rb
puppet-2.6.4 spec/integration/parser/collector_spec.rb
puppet-2.6.3 spec/integration/parser/collector_spec.rb
puppet-2.6.2 spec/integration/parser/collector_spec.rb
puppet-2.6.1 spec/integration/parser/collector_spec.rb
puppet-2.6.0 spec/integration/parser/collector_spec.rb