Skip to content

Commit

Permalink
make PageTextReceiver::DEFAULT_GRAPHICS_STATE immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
tardate committed Jan 9, 2012
1 parent 46bfdad commit 5421138
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pdf/reader/page_text_receiver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def page=(page)
@font_stack = [build_fonts(page.fonts)]
@xobject_stack = [page.xobjects]
@content = {}
@stack = [DEFAULT_GRAPHICS_STATE]
@stack = [DEFAULT_GRAPHICS_STATE.dup]
end

def content
Expand Down
20 changes: 20 additions & 0 deletions spec/page_text_receiver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,24 @@

@receiver.content.should eql("one\ntwo\nthree\nfour")
end

describe "##DEFAULT_GRAPHICS_STATE" do
subject { PDF::Reader::PageTextReceiver::DEFAULT_GRAPHICS_STATE }

context "when walking more than one document" do
let!(:expect) { PDF::Reader::PageTextReceiver::DEFAULT_GRAPHICS_STATE.dup }
before do
2.times do
page = PDF::Reader.new(pdf_spec_file("adobe_sample")).page(1)
receiver = PDF::Reader::PageTextReceiver.new
page.walk(receiver)
end
end
it "should not mutate" do
should eql(expect)
end
end

end

end

0 comments on commit 5421138

Please sign in to comment.