Sha256: 022c71f1e54b15661b60156c60585383c761c7f682f4cf5f9a4a1375473b0013

Contents?: true

Size: 1.95 KB

Versions: 8

Compression:

Stored size: 1.95 KB

Contents

require 'spec_helper'

describe Hieracles::Formats::Json do
  let(:node) { double("node") }
  let(:json_format) { Hieracles::Formats::Json.new node }

  describe ".info" do
    let(:expected) { '{"Node":"fqdn","Farm":"farm"}' }
    before {
      allow(node).to receive(:info).and_return(
        {
          'Node' => 'fqdn',
          'Farm' => 'farm'
        }
      )
    }
    it { expect(json_format.info nil).to eq expected }
  end

  describe ".files" do
    let(:expected) { '["path1","path2"]' }
    before {
      allow(node).to receive(:files).and_return(['path1', 'path2'])
    }
    it { expect(json_format.files nil).to eq expected }
  end

  describe ".paths" do
    let(:expected) { '["path1","path2"]' }
    before {
      allow(node).to receive(:paths).and_return(['path1', 'path2'])
    }
    it { expect(json_format.paths nil).to eq expected }
  end

  describe ".modules" do
    let(:expected) { "---\nmodule1: value\nlongmodule2: not found\n" }
    let(:expected) { '{"module1":"value","longmodule2":"not found"}' }
    before {
      allow(node).to receive(:modules).and_return(
        { 
          'module1' => "value", 
          'longmodule2' => "not found"
        }
      )
    }
    it { expect(json_format.modules nil).to eq expected }
  end

  describe ".params" do
    let(:expected) { '{"params":{"this":{"var":"value1"}}}' }
    before {
      allow(node).to receive(:params).and_return(
        { 
          'params' => {
            'this' => {
              'var' => 'value1'
            }
          }
        }
      )
    }
    it { expect(json_format.params nil).to eq expected }
  end

  describe ".allparams" do
    let(:expected) { '{"params":{"this":{"var":"value1"}}}' }
    before {
      allow(node).to receive(:params).and_return(
        { 
          'params' => {
            'this' => {
              'var' => 'value1'
            }
          }
        }
      )
    }
    it { expect(json_format.allparams nil).to eq expected }
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hieracles-0.2.0 spec/lib/formats/json_spec.rb
hieracles-0.1.7 spec/lib/formats/json_spec.rb
hieracles-0.1.6 spec/lib/formats/json_spec.rb
hieracles-0.1.5 spec/lib/formats/json_spec.rb
hieracles-0.1.4 spec/lib/formats/json_spec.rb
hieracles-0.1.3 spec/lib/formats/json_spec.rb
hieracles-0.1.2 spec/lib/formats/json_spec.rb
hieracles-0.1.1 spec/lib/formats/json_spec.rb