Sha256: 821031f21099249990a5dc1cc82c3f7f1f8e84b20a83ff20ef9b4ce8a7447284

Contents?: true

Size: 1.58 KB

Versions: 9

Compression:

Stored size: 1.58 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2008-3-28.
#  Copyright (c) 2008. All rights reserved.

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

require 'puppet/util/ldap/generator'

describe Puppet::Util::Ldap::Generator do
    before do
        @generator = Puppet::Util::Ldap::Generator.new(:uno)
    end

    it "should require a parameter name at initialization" do
        lambda { Puppet::Util::Ldap::Generator.new }.should raise_error
    end

    it "should always return its name as a string" do
        g = Puppet::Util::Ldap::Generator.new(:myname)
        g.name.should == "myname"
    end

    it "should provide a method for declaring the source parameter" do
        @generator.from(:dos)
    end

    it "should always return a set source as a string" do
        @generator.from(:dos)
        @generator.source.should == "dos"
    end

    it "should return the source as nil if there is no source" do
        @generator.source.should be_nil
    end

    it "should return itself when declaring the source" do
        @generator.from(:dos).should equal(@generator)
    end

    it "should run the provided block when asked to generate the value" do
        @generator.with { "yayness" }
        @generator.generate().should == "yayness"
    end

    it "should pass in any provided value to the block" do
        @generator.with { |value| value.upcase }
        @generator.generate("myval").should == "MYVAL"
    end

    it "should return itself when declaring the code used for generating" do
        @generator.with { |value| value.upcase }.should equal(@generator)
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
puppet-0.25.5 spec/unit/util/ldap/generator.rb
puppet-0.25.4 spec/unit/util/ldap/generator.rb
puppet-0.25.3 spec/unit/util/ldap/generator.rb
puppet-0.24.9 spec/unit/util/ldap/generator.rb
puppet-0.25.2 spec/unit/util/ldap/generator.rb
puppet-0.25.1 spec/unit/util/ldap/generator.rb
puppet-0.25.0 spec/unit/util/ldap/generator.rb
puppet-0.24.7 spec/unit/util/ldap/generator.rb
puppet-0.24.8 spec/unit/util/ldap/generator.rb