summaryrefslogtreecommitdiffstats
path: root/spec/unit/util/json.rb
blob: 5ef5dc6ac0e681e3d480f0a22719af6eb1f85924 (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/json'

class JsonUtil
    include Puppet::Util::Json
end

describe Puppet::Util::Json do
    it "should fail if no data is provided" do
        lambda { JsonUtil.new.json_create("json_class" => "foo") }.should raise_error(ArgumentError)
    end

    it "should call 'from_json' with the provided data" do
        json = JsonUtil.new
        json.expects(:from_json).with("mydata")
        json.json_create("json_class" => "foo", "data" => "mydata")
    end
end