File: status_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-- 1,228 bytes parent folder | download | duplicates (2)
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 'matchers/json'

describe Puppet::Status do
  include JSONMatchers

  it "should implement find" do
    expect(Puppet::Status.indirection.find( :default )).to be_is_a(Puppet::Status)
    expect(Puppet::Status.indirection.find( :default ).status["is_alive"]).to eq(true)
  end

  it "should default to is_alive is true" do
    expect(Puppet::Status.new.status["is_alive"]).to eq(true)
  end

  it "should return a pson hash" do
    expect(Puppet::Status.new.status.to_pson).to eq('{"is_alive":true}')
  end

  it "should render to a pson hash" do
    expect(PSON::pretty_generate(Puppet::Status.new)).to match(/"is_alive":\s*true/)
  end

  it "should accept a hash from pson" do
    status = Puppet::Status.new( { "is_alive" => false } )
    expect(status.status).to eq({ "is_alive" => false })
  end

  it "should have a name" do
    Puppet::Status.new.name
  end

  it "should allow a name to be set" do
    Puppet::Status.new.name = "status"
  end

  it "serializes to PSON that conforms to the status schema" do
    status = Puppet::Status.new
    status.version = Puppet.version

    expect(status.render('pson')).to validate_against('api/schemas/status.json')
  end
end