require 'spec_helper' require 'plist4r' describe Plist4r, "#new" do before(:each) do @plist = Plist4r::Plist.new Plist4r::Plist.stub!(:new).and_return(@plist) end it "should return a Plist4r::Plist object" do Plist4r.new.should be_a_kind_of(Plist4r::Plist) end it "should call Plist4r::Plist.new with the supplied arguments and return @plist" do Plist4r::Plist.should_receive(:new).with(:arg1, :arg2, :arg3, :etc) @result = Plist4r.new(:arg1, :arg2, :arg3, :etc) @result.should == @plist end end describe Plist4r, "#open" do before(:each) do @plist = Plist4r::Plist.new @plist.stub!(:open).and_return(@plist) Plist4r::Plist.stub!(:new).and_return(@plist) end it "should return a Plist4r::Plist object" do Plist4r.new.should be_a_kind_of(Plist4r::Plist) end it "should call Plist4r::Plist.new with the supplied arguments and return @plist" do Plist4r::Plist.should_receive(:new).with("filename", :arg2, :arg3, :etc) Plist4r.open("filename", :arg2, :arg3, :etc).should == @plist end it "should call @plist.open" do @plist.should_receive(:open) @result = Plist4r.open("filename", :arg2, :arg3, :etc) end end describe Plist4r, "#string_detect_format" do before(:each) do @plist_str_gnustep1 = " (" @plist_str_gnustep2 = " {" @plist_str_xml = " @string) @string.to_plist.should == @plist end end