File: splayer_spec.rb

package info (click to toggle)
puppet 4.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 20,736 kB
  • ctags: 14,616
  • sloc: ruby: 236,754; xml: 1,586; sh: 1,178; lisp: 299; sql: 103; yacc: 72; makefile: 52
file content (45 lines) | stat: -rw-r--r-- 991 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet/util/splayer'

describe Puppet::Util::Splayer do
  include Puppet::Util::Splayer

  let (:subject) { self }

  before do
    Puppet[:splay] = true
    Puppet[:splaylimit] = "10"
  end

  it "should do nothing if splay is disabled" do
    Puppet[:splay] = false
    subject.expects(:sleep).never
    subject.splay
  end

  it "should do nothing if it has already splayed" do
    subject.expects(:splayed?).returns true
    subject.expects(:sleep).never
    subject.splay
  end

  it "should log that it is splaying" do
    subject.stubs :sleep
    Puppet.expects :info
    subject.splay
  end

  it "should sleep for a random portion of the splaylimit plus 1" do
    Puppet[:splaylimit] = "50"
    subject.expects(:rand).with(51).returns 10
    subject.expects(:sleep).with(10)
    subject.splay
  end

  it "should mark that it has splayed" do
    subject.stubs(:sleep)
    subject.splay
    expect(subject).to be_splayed
  end
end