spec/reference_spec.rb in prawn-1.0.0.rc1 vs spec/reference_spec.rb in prawn-1.0.0.rc2
- old
+ new
@@ -33,11 +33,11 @@
cref = Prawn::Core::Reference(2,{})
cref << "Hi There " * 20
cref.compress_stream
- assert cref.stream.size < ref.stream.size,
+ cref.stream.size.should be < ref.stream.size,
"compressed stream expected to be smaller than source but wasn't"
cref.data[:Filter].should == :FlateDecode
end
it "should copy the data and stream from another ref on #replace" do
@@ -65,18 +65,41 @@
to.data.should == from.data
to.stream.should == from.stream
to.compressed?.should == true
end
+ it "should have Length if stream present" do
+ ref = Prawn::Core::Reference(7, {})
+ ref << "Hello"
+
+ ref.data[:Length].should == 5
+ end
+
+ it "should update Length when stream is updated" do
+ ref = Prawn::Core::Reference(7, {})
+ ref << "Hello"
+ ref.data[:Length].should == 5
+
+ ref << " world"
+ ref.data[:Length].should == 11
+ end
+
describe "generated via Prawn::Document" do
it "should return a proper reference on ref!" do
pdf = Prawn::Document.new
pdf.ref!({}).is_a?(Prawn::Core::Reference).should == true
end
it "should return an identifier on ref" do
pdf = Prawn::Document.new
r = pdf.ref({})
r.is_a?(Integer).should == true
+ end
+
+ it "should have :Length of stream if it has one when compression disabled" do
+ pdf = Prawn::Document.new :compress => false
+ ref = pdf.ref!({})
+ ref << 'Hello'
+ ref.data[:Length].should == 5
end
end
end