spec/encoding/encoding_spec.rb in brianmario-yajl-ruby-0.5.0 vs spec/encoding/encoding_spec.rb in brianmario-yajl-ruby-0.5.1

- old
+ new

@@ -23,6 +23,26 @@ hash.should == hash2 end end end + + it "should encode with :pretty turned on and a single space indent" do + output = "{\n \"foo\": {\n \"name\": \"bar\",\n \"id\": 1234\n }\n}\n" + obj = {:foo => {:id => 1234, :name => "bar"}} + io = StringIO.new + encoder = Yajl::Encoder.new(:pretty => true, :indent => ' ') + encoder.encode(obj, io) + io.rewind + io.read.should == output + end + + it "should encode with :pretty turned on and a tab character indent" do + output = "{\n\t\"foo\": {\n\t\t\"name\": \"bar\",\n\t\t\"id\": 1234\n\t}\n}\n" + obj = {:foo => {:id => 1234, :name => "bar"}} + io = StringIO.new + encoder = Yajl::Encoder.new(:pretty => true, :indent => "\t") + encoder.encode(obj, io) + io.rewind + io.read.should == output + end end \ No newline at end of file