Sha256: 03354e5be8e77169adcc94ec3c7b1b6d32e13e30edd86f37b218cb306c1294a2

Contents?: true

Size: 1.54 KB

Versions: 15

Compression:

Stored size: 1.54 KB

Contents

#!/usr/bin/env rspec

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

describe Puppet::Util::Instrumentation::Data do
  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_pson({:name => "name"}).should == {:name => "name"}
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
puppet-2.7.26 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.25 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.24 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.23 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.22 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.21 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.20 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.20.rc1 spec/unit/util/instrumentation/data_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.19 spec/unit/util/instrumentation/data_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.18 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.17 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.16 spec/unit/util/instrumentation/data_spec.rb
puppet-2.7.14 spec/unit/util/instrumentation/data_spec.rb