Sha256: 9b83e437bd8952236d09f00de07668dcdc054bdaf842c7016e19f7bef0064437

Contents?: true

Size: 1.57 KB

Versions: 57

Compression:

Stored size: 1.57 KB

Contents

#! /usr/bin/env ruby

require 'spec_helper'
require 'matchers/json'
require 'puppet/util/instrumentation'
require 'puppet/util/instrumentation/data'

describe Puppet::Util::Instrumentation::Data do
  include JSONMatchers

  Puppet::Util::Instrumentation::Data

  before(:each) do
    @listener = stub 'listener', :name => "name"
    Puppet::Util::Instrumentation.stubs(:[]).with("name").returns(@listener)
  end

  it "should indirect instrumentation_data" do
    Puppet::Util::Instrumentation::Data.indirection.name.should == :instrumentation_data
  end

  it "should lookup the corresponding listener" do
    Puppet::Util::Instrumentation.expects(:[]).with("name").returns(@listener)
    Puppet::Util::Instrumentation::Data.new("name")
  end

  it "should error if the listener can not be found" do
    Puppet::Util::Instrumentation.expects(:[]).with("name").returns(nil)
    expect { Puppet::Util::Instrumentation::Data.new("name") }.to raise_error
  end

  it "should return pson data" do
    data = Puppet::Util::Instrumentation::Data.new("name")
    @listener.stubs(:data).returns({ :this_is_data  => "here also" })
    data.should set_json_attribute('name').to("name")
    data.should set_json_attribute('this_is_data').to("here also")
  end

  it "should not error if the underlying listener doesn't have data" do
    lambda { Puppet::Util::Instrumentation::Data.new("name").to_pson }.should_not raise_error
  end

  it "should return a hash containing data when unserializing from pson" do
    Puppet::Util::Instrumentation::Data.from_data_hash({:name => "name"}).should == {:name => "name"}
  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

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