Sha256: a7a8984a45805966662e7af1b673ab3cf23f65227145b82841b6f83f236448e0

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

require 'puppet/parser/collector'

describe Puppet::Parser::Collector do
  before do
    @scope = Puppet::Parser::Scope.new(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)
    return parser.parse(code).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

7 entries across 7 versions & 1 rubygems

Version Path
puppet-3.0.2 spec/integration/parser/collector_spec.rb
puppet-3.0.2.rc3 spec/integration/parser/collector_spec.rb
puppet-3.0.2.rc2 spec/integration/parser/collector_spec.rb
puppet-3.0.2.rc1 spec/integration/parser/collector_spec.rb
puppet-3.0.1 spec/integration/parser/collector_spec.rb
puppet-3.0.1.rc1 spec/integration/parser/collector_spec.rb
puppet-3.0.0 spec/integration/parser/collector_spec.rb