spec/obj_spec.rb in podoff-1.1.1 vs spec/obj_spec.rb in podoff-1.2.0
- old
+ new
@@ -10,11 +10,11 @@
describe Podoff::Obj do
before :all do
- @d = Podoff.load('pdfs/udocument0.pdf')
+ @d = Podoff.load('pdfs/udocument0.pdf', 'iso-8859-1')
end
describe '#document' do
it 'points to the Podoff::Document owning this Obj' do
@@ -28,11 +28,12 @@
it 'returns the source behind the obj' do
o = @d.objs['20 0']
expect(o.source).to eq(%{
-20 0 obj [21 0 R]
+20 0 obj
+<< /DA (/Calibri,Bold 10 Tf 0 g) /F 4 /FT /Tx /MK << >> /P 58 0 R /Rect [ 448.723 652.574 490.603 667.749 ] /Subtype /Widget /T (State) /TU (State) /Type /Annot >>
endobj
}.strip)
end
end
@@ -84,16 +85,16 @@
describe '#type' do
it 'returns the type of the obj' do
- expect(@d.objs['23 0'].type).to eq('/Font')
+ expect(@d.objs['12 0'].type).to eq('/Font')
end
it 'returns nil if there is no type' do
- expect(@d.objs['17 0'].type).to eq(nil)
+ expect(@d.objs['59 0'].type).to eq(nil)
end
it 'works on open streams' do
st = @d.add_stream
@@ -148,11 +149,11 @@
context 'insertions' do
before :each do
- @d = Podoff.load('pdfs/udocument0.pdf')
+ @d = Podoff.load('pdfs/udocument0.pdf', 'iso-8859-1')
end
describe '#insert_contents' do
it 'fails if the target hasn\'t been replicated' do
@@ -176,22 +177,22 @@
st = @d.add_stream('BT 70 80 Td /Font0 35 Tf (content is king!) Tj ET')
pa.insert_contents(st)
- expect(pa.source).to match(/\/Contents \[3 0 R #{st.ref} R\]\n/)
+ expect(pa.source).to match(/\/Contents \[151 0 R #{st.ref} R\]/)
end
it 'accepts an obj ref' do
pa = @d.re_add(@d.page(1))
st = @d.add_stream('BT 70 80 Td /Font0 35 Tf (content is king!) Tj ET')
pa.insert_contents(st.ref)
- expect(pa.source).to match(/\/Contents \[3 0 R #{st.ref} R\]\n/)
+ expect(pa.source).to match(/\/Contents \[151 0 R #{st.ref} R\]/)
end
end
describe '#insert_font' do
@@ -235,17 +236,17 @@
describe '#add_to_attribute' do
it 'adds to a list of references' do
- d = Podoff.load('pdfs/qdocument0.pdf')
+ d = Podoff.load('pdfs/qdocument0.pdf', 'iso-8859-1')
o = d.re_add('56 0')
o.send(:add_to_attribute, :contents, '9999 0')
expect(o.attributes).to eq(
- { type: '/Page', contents: '[151 0 R 9999 0 R]', pagenum: '1' })
+ { type: '/Page', contents: '[151 0 R 9999 0 R]' })
end
end
end
end