spec/unit/indirector/queue.rb in puppet-0.25.0 vs spec/unit/indirector/queue.rb in puppet-0.25.1
- old
+ new
@@ -7,29 +7,29 @@
end
class FooExampleData
attr_accessor :name
- def self.json_create(json)
- new(json['data'].to_sym)
+ def self.pson_create(pson)
+ new(pson['data'].to_sym)
end
def initialize(name = nil)
@name = name if name
end
- def render(format = :json)
- to_json
+ def render(format = :pson)
+ to_pson
end
- def to_json(*args)
- {:json_class => self.class.to_s, :data => name}.to_json(*args)
+ def to_pson(*args)
+ {:type => self.class.to_s, :data => name}.to_pson(*args)
end
end
describe Puppet::Indirector::Queue do
- confine "JSON library is missing; cannot test queueing" => Puppet.features.json?
+ confine "PSON library is missing; cannot test queueing" => Puppet.features.pson?
before :each do
@model = mock 'model'
@indirection = stub 'indirection', :name => :my_queue, :register_terminus_type => nil, :model => @model
Puppet::Indirector::Indirection.stubs(:instance).with(:my_queue).returns(@indirection)
@@ -49,32 +49,32 @@
Puppet::Util::Queue.stubs(:queue_type_to_class).with(:test_client).returns(Puppet::Indirector::Queue::TestClient)
@request = stub 'request', :key => :me, :instance => @subject
end
- it "should require JSON" do
- Puppet.features.expects(:json?).returns false
+ it "should require PSON" do
+ Puppet.features.expects(:pson?).returns false
lambda { @store_class.new }.should raise_error(ArgumentError)
end
it 'should use the correct client type and queue' do
@store.queue.should == :my_queue
@store.client.should be_an_instance_of(Puppet::Indirector::Queue::TestClient)
end
describe "when saving" do
- it 'should render the instance using json' do
- @subject.expects(:render).with(:json)
+ it 'should render the instance using pson' do
+ @subject.expects(:render).with(:pson)
@store.client.stubs(:send_message)
@store.save(@request)
end
it "should send the rendered message to the appropriate queue on the client" do
- @subject.expects(:render).returns "myjson"
+ @subject.expects(:render).returns "mypson"
- @store.client.expects(:send_message).with(:my_queue, "myjson")
+ @store.client.expects(:send_message).with(:my_queue, "mypson")
@store.save(@request)
end
it "should catch any exceptions raised" do
@@ -87,11 +87,11 @@
describe "when subscribing to the queue" do
before do
@store_class.stubs(:model).returns @model
end
- it "should use the model's Format support to intern the message from json" do
- @model.expects(:convert_from).with(:json, "mymessage")
+ it "should use the model's Format support to intern the message from pson" do
+ @model.expects(:convert_from).with(:pson, "mymessage")
@store_class.client.expects(:subscribe).yields("mymessage")
@store_class.subscribe {|o| o }
end