Sha256: 6094c3e367513c1da69db269af0e23db1ead396b0831bc63b8e84cdd19b1c309

Contents?: true

Size: 1.39 KB

Versions: 4

Compression:

Stored size: 1.39 KB

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'
require 'puppet/util/rails/reference_serializer'

class SerializeTester
  include Puppet::Util::ReferenceSerializer
end

describe Puppet::Util::ReferenceSerializer do
  before do
    @tester = SerializeTester.new
  end

  describe "when serializing" do
    it "should yaml-dump resource references" do
      ref = Puppet::Resource.new("file", "/foo")
      @tester.serialize_value(ref).should =~ /^---/
    end

    it "should convert the boolean 'true' into the string 'true'" do
      @tester.serialize_value(true).should == "true"
    end

    it "should convert the boolean 'false' into the string 'false'" do
      @tester.serialize_value(false).should == "false"
    end

    it "should return all other values" do
      @tester.serialize_value("foo").should == "foo"
    end
  end

  describe "when unserializing" do
    it "should yaml-load values that look like yaml" do
      yaml = YAML.dump(%w{a b c})
      @tester.unserialize_value(yaml).should == %w{a b c}
    end

    it "should convert the string 'true' into the boolean 'true'" do
      @tester.unserialize_value("true").should == true
    end

    it "should convert the string 'false' into the boolean 'false'" do
      @tester.unserialize_value("false").should == false
    end

    it "should return all other values" do
      @tester.unserialize_value("foo").should == "foo"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/util/reference_serializer_spec.rb
puppet-3.0.0.rc7 spec/unit/util/reference_serializer_spec.rb
puppet-3.0.0.rc5 spec/unit/util/reference_serializer_spec.rb
puppet-3.0.0.rc4 spec/unit/util/reference_serializer_spec.rb