Sha256: c5e8da49ac26a588c65e04508719c9031c5fae797674e7d2eca924d683760875

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/util/ldap/generator_spec.rb
puppet-3.0.0.rc7 spec/unit/util/ldap/generator_spec.rb
puppet-3.0.0.rc5 spec/unit/util/ldap/generator_spec.rb
puppet-3.0.0.rc4 spec/unit/util/ldap/generator_spec.rb