Sha256: 87cd928c3ee348c0d69738f3c64760d8ca1dc75494aa3964729c7d6c0ab428fe

Contents?: true

Size: 1.37 KB

Versions: 35

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env rspec
require '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)
    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

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 spec/integration/parser/collector_spec.rb
puppet-2.7.25 spec/integration/parser/collector_spec.rb
puppet-2.7.24 spec/integration/parser/collector_spec.rb
puppet-2.7.23 spec/integration/parser/collector_spec.rb
puppet-2.7.22 spec/integration/parser/collector_spec.rb
puppet-2.7.21 spec/integration/parser/collector_spec.rb
puppet-2.7.20 spec/integration/parser/collector_spec.rb
puppet-2.7.20.rc1 spec/integration/parser/collector_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/integration/parser/collector_spec.rb
puppet-2.7.19 spec/integration/parser/collector_spec.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/integration/parser/collector_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/integration/parser/collector_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/integration/parser/collector_spec.rb
puppet-2.7.18 spec/integration/parser/collector_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/integration/parser/collector_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/integration/parser/collector_spec.rb
puppet-2.7.17 spec/integration/parser/collector_spec.rb
puppet-2.7.16 spec/integration/parser/collector_spec.rb
puppet-2.7.14 spec/integration/parser/collector_spec.rb
puppet-2.7.13 spec/integration/parser/collector_spec.rb