Sha256: b1dfdea4f64f744b6c1d43c6859a4ec72d278af46dffbf898f279b286997077b

Contents?: true

Size: 1.37 KB

Versions: 92

Compression:

Stored size: 1.37 KB

Contents

#! /usr/bin/env ruby
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

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.6 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.5 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.4 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.3 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.2 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.1 spec/unit/util/ldap/generator_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/util/ldap/generator_spec.rb