summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/json_spec.rb
blob: 4f6cea9976cca6cf089764d596cf3572130f9d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env ruby

Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }

require 'puppet/util/pson'

class PsonUtil
  include Puppet::Util::Pson
end

describe Puppet::Util::Pson do
  it "should fail if no data is provided" do
    lambda { PsonUtil.new.pson_create("type" => "foo") }.should raise_error(ArgumentError)
  end

  it "should call 'from_pson' with the provided data" do
    pson = PsonUtil.new
    pson.expects(:from_pson).with("mydata")
    pson.pson_create("type" => "foo", "data" => "mydata")
  end
end