From 4f878b3179e12cc8f7a662dd76aafa4a2bcf75a8 Mon Sep 17 00:00:00 2001
From: James Healy
Date: Fri, 19 Nov 2010 08:36:28 -0500
Subject: [PATCH] modernise packaging
* remove cruft from Rakefile
* switch to bundler to manage the $LOAD_PATH in development
* upgrade rspec from 1.x to 2.x
---
Gemfile | 3 +
Gemfile.lock | 35 ++++++
Rakefile | 33 ++----
pdf-reader.gemspec | 5 +
{specs => spec}/buffer_spec.rb | 104 +++++++++---------
{specs => spec}/callback_spec.rb | 40 +++----
{specs => spec}/cmap_spec.rb | 12 +-
.../data/20070313 - 2nd Laptop Battery.pdf | Bin
{specs => spec}/data/adobe_sample.pdf | Bin
{specs => spec}/data/ascii85_filter.pdf | Bin
{specs => spec}/data/broken_string.pdf | Bin
{specs => spec}/data/cairo-basic.pdf | Bin
{specs => spec}/data/cairo-unicode-short.pdf | Bin
{specs => spec}/data/cairo-unicode.pdf | Bin
{specs => spec}/data/cmap_with_bfchar.txt | 0
{specs => spec}/data/cmap_with_bfrange.txt | 0
.../data/cmap_with_bfrange_three.txt | 0
.../data/cmap_with_bfrange_two.txt | 0
.../content_stream_missing_final_operator.pdf | Bin
.../content_stream_refers_to_invalid_font.pdf | Bin
.../content_stream_trailing_whitespace.pdf | Bin
.../content_stream_with_length_as_ref.pdf | Bin
..._with_length_as_ref_and_windows_breaks.pdf | Bin
{specs => spec}/data/cross_ref_stream.pdf | Bin
.../data/deflated_with_predictors.dat | Bin
.../data/deflated_with_predictors_result.dat | Bin
{specs => spec}/data/difference_table.pdf | Bin
.../data/difference_table_encrypted.pdf | Bin
{specs => spec}/data/distiller_unicode.pdf | Bin
{specs => spec}/data/dutch.pdf | Bin
{specs => spec}/data/form_xobject.pdf | Bin
{specs => spec}/data/form_xobject_more.pdf | Bin
{specs => spec}/data/hard_lock_under_osx.pdf | Bin
{specs => spec}/data/indirect_xobject.pdf | Bin
{specs => spec}/data/inline_image.pdf | Bin
...nline_image_single_line_content_stream.pdf | Bin
{specs => spec}/data/invalid/data.csv | 0
.../invalid/linearized_bad_xref_offset.pdf | Bin
{specs => spec}/data/invalid/no_eof.pdf | Bin
{specs => spec}/data/invalid/no_trailer.pdf | Bin
.../data/invalid/trailer_is_not_a_dict.pdf | Bin
.../data/large_single_line_content_stream.pdf | Bin
{specs => spec}/data/lzw_compressed.dat | 0
{specs => spec}/data/lzw_decompressed.dat | 0
{specs => spec}/data/lzw_stream.pdf | Bin
{specs => spec}/data/no_text_spaces.pdf | Bin
{specs => spec}/data/oo3.pdf | Bin
{specs => spec}/data/openoffice-2.2.pdf | Bin
{specs => spec}/data/osx_print_unicode.pdf | Bin
{specs => spec}/data/pdf-distiller.pdf | Bin
{specs => spec}/data/pdflatex.pdf | Bin
{specs => spec}/data/pdfwriter-manual.pdf | Bin
{specs => spec}/data/prince1.pdf | Bin
{specs => spec}/data/prince2.pdf | Bin
{specs => spec}/data/screwey_xref_offsets.pdf | Bin
{specs => spec}/data/space_after_eof.pdf | Bin
.../data/split_params_and_operator.pdf | Bin
{specs => spec}/data/xref_subsections.pdf | Bin
{specs => spec}/data/zlib_stream_issue.pdf | Bin
{specs => spec}/encoding_spec.rb | 78 ++++++-------
{specs => spec}/filter_spec.rb | 22 ++--
{specs => spec}/font_spec.rb | 14 +--
{specs => spec}/lzw_spec.rb | 2 +-
{specs => spec}/meta_spec.rb | 40 +++----
{specs => spec}/metadata_spec.rb | 12 +-
{specs => spec}/object_hash_spec.rb | 100 ++++++++---------
{specs => spec}/object_stream_spec.rb | 10 +-
{specs => spec}/pages_visitor_spec.rb | 10 +-
{specs => spec}/parser_spec.rb | 26 ++---
{specs => spec}/reader_spec.rb | 40 +++----
{specs => spec}/spec_helper.rb | 4 +-
{specs => spec}/stream_spec.rb | 8 +-
{specs => spec}/xref_spec.rb | 28 ++---
73 files changed, 326 insertions(+), 300 deletions(-)
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
rename {specs => spec}/buffer_spec.rb (72%)
rename {specs => spec}/callback_spec.rb (89%)
rename {specs => spec}/cmap_spec.rb (80%)
rename {specs => spec}/data/20070313 - 2nd Laptop Battery.pdf (100%)
rename {specs => spec}/data/adobe_sample.pdf (100%)
rename {specs => spec}/data/ascii85_filter.pdf (100%)
rename {specs => spec}/data/broken_string.pdf (100%)
rename {specs => spec}/data/cairo-basic.pdf (100%)
rename {specs => spec}/data/cairo-unicode-short.pdf (100%)
rename {specs => spec}/data/cairo-unicode.pdf (100%)
rename {specs => spec}/data/cmap_with_bfchar.txt (100%)
rename {specs => spec}/data/cmap_with_bfrange.txt (100%)
rename {specs => spec}/data/cmap_with_bfrange_three.txt (100%)
rename {specs => spec}/data/cmap_with_bfrange_two.txt (100%)
rename {specs => spec}/data/content_stream_missing_final_operator.pdf (100%)
rename {specs => spec}/data/content_stream_refers_to_invalid_font.pdf (100%)
rename {specs => spec}/data/content_stream_trailing_whitespace.pdf (100%)
rename {specs => spec}/data/content_stream_with_length_as_ref.pdf (100%)
rename {specs => spec}/data/content_stream_with_length_as_ref_and_windows_breaks.pdf (100%)
rename {specs => spec}/data/cross_ref_stream.pdf (100%)
rename {specs => spec}/data/deflated_with_predictors.dat (100%)
rename {specs => spec}/data/deflated_with_predictors_result.dat (100%)
rename {specs => spec}/data/difference_table.pdf (100%)
rename {specs => spec}/data/difference_table_encrypted.pdf (100%)
rename {specs => spec}/data/distiller_unicode.pdf (100%)
rename {specs => spec}/data/dutch.pdf (100%)
rename {specs => spec}/data/form_xobject.pdf (100%)
rename {specs => spec}/data/form_xobject_more.pdf (100%)
rename {specs => spec}/data/hard_lock_under_osx.pdf (100%)
rename {specs => spec}/data/indirect_xobject.pdf (100%)
rename {specs => spec}/data/inline_image.pdf (100%)
rename {specs => spec}/data/inline_image_single_line_content_stream.pdf (100%)
rename {specs => spec}/data/invalid/data.csv (100%)
rename {specs => spec}/data/invalid/linearized_bad_xref_offset.pdf (100%)
rename {specs => spec}/data/invalid/no_eof.pdf (100%)
rename {specs => spec}/data/invalid/no_trailer.pdf (100%)
rename {specs => spec}/data/invalid/trailer_is_not_a_dict.pdf (100%)
rename {specs => spec}/data/large_single_line_content_stream.pdf (100%)
rename {specs => spec}/data/lzw_compressed.dat (100%)
rename {specs => spec}/data/lzw_decompressed.dat (100%)
rename {specs => spec}/data/lzw_stream.pdf (100%)
rename {specs => spec}/data/no_text_spaces.pdf (100%)
rename {specs => spec}/data/oo3.pdf (100%)
rename {specs => spec}/data/openoffice-2.2.pdf (100%)
rename {specs => spec}/data/osx_print_unicode.pdf (100%)
rename {specs => spec}/data/pdf-distiller.pdf (100%)
rename {specs => spec}/data/pdflatex.pdf (100%)
rename {specs => spec}/data/pdfwriter-manual.pdf (100%)
rename {specs => spec}/data/prince1.pdf (100%)
rename {specs => spec}/data/prince2.pdf (100%)
rename {specs => spec}/data/screwey_xref_offsets.pdf (100%)
rename {specs => spec}/data/space_after_eof.pdf (100%)
rename {specs => spec}/data/split_params_and_operator.pdf (100%)
rename {specs => spec}/data/xref_subsections.pdf (100%)
rename {specs => spec}/data/zlib_stream_issue.pdf (100%)
rename {specs => spec}/encoding_spec.rb (79%)
rename {specs => spec}/filter_spec.rb (77%)
rename {specs => spec}/font_spec.rb (70%)
rename {specs => spec}/lzw_spec.rb (92%)
rename {specs => spec}/meta_spec.rb (80%)
rename {specs => spec}/metadata_spec.rb (80%)
rename {specs => spec}/object_hash_spec.rb (69%)
rename {specs => spec}/object_stream_spec.rb (79%)
rename {specs => spec}/pages_visitor_spec.rb (88%)
rename {specs => spec}/parser_spec.rb (88%)
rename {specs => spec}/reader_spec.rb (72%)
rename {specs => spec}/spec_helper.rb (97%)
rename {specs => spec}/stream_spec.rb (91%)
rename {specs => spec}/xref_spec.rb (68%)
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 00000000..632c37e0
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,3 @@
+source :gemcutter
+
+gemspec
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 00000000..6b4fc808
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,35 @@
+PATH
+ remote: .
+ specs:
+ pdf-reader (0.8.5)
+ Ascii85 (>= 0.9)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ Ascii85 (1.0.0)
+ diff-lcs (1.1.2)
+ rake (0.8.7)
+ roodi (2.1.0)
+ ruby_parser
+ rspec (2.1.0)
+ rspec-core (~> 2.1.0)
+ rspec-expectations (~> 2.1.0)
+ rspec-mocks (~> 2.1.0)
+ rspec-core (2.1.0)
+ rspec-expectations (2.1.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.1.0)
+ ruby_parser (2.0.5)
+ sexp_processor (~> 3.0)
+ sexp_processor (3.0.5)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ Ascii85 (>= 0.9)
+ pdf-reader!
+ rake
+ roodi
+ rspec (~> 2.1)
diff --git a/Rakefile b/Rakefile
index 0b7658dc..7d041f39 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,10 @@
require "rubygems"
+require "bundler"
+Bundler.setup
+
require 'rake'
-require 'rake/clean'
require 'rake/rdoctask'
-require 'rake/testtask'
-require "rake/gempackagetask"
-require 'spec/rake/spectask'
+require 'rspec/core/rake_task'
require 'roodi'
require 'roodi_task'
@@ -13,28 +13,9 @@ task :default => [ :spec ]
# run all rspecs
desc "Run all rspec files"
-Spec::Rake::SpecTask.new("spec") do |t|
- t.spec_files = FileList['specs/**/*.rb']
- t.spec_opts = ["--color", "--format progress"]
- t.rcov = false
- t.ruby_opts << "-w"
-end
-
-# generate specdocs
-desc "Generate Specdocs"
-Spec::Rake::SpecTask.new("specdocs") do |t|
- t.spec_files = FileList['specs/**/*.rb']
- t.spec_opts = ["--format", "rdoc"]
- t.out = (ENV['CC_BUILD_ARTIFACTS'] || 'doc') + '/specdoc.rd'
-end
-
-# generate failing spec report
-desc "Generate failing spec report"
-Spec::Rake::SpecTask.new("spec_report") do |t|
- t.spec_files = FileList['specs/**/*.rb']
- t.spec_opts = ["--format", "html", "--diff"]
- t.out = (ENV['CC_BUILD_ARTIFACTS'] || 'doc') + '/spec_report.html'
- t.fail_on_error = false
+RSpec::Core::RakeTask.new("spec") do |t|
+ t.rspec_opts = ["--color", "--format progress"]
+ t.ruby_opts = "-w"
end
# Genereate the RDoc documentation
diff --git a/pdf-reader.gemspec b/pdf-reader.gemspec
index 74923cdd..4dfbc0c4 100644
--- a/pdf-reader.gemspec
+++ b/pdf-reader.gemspec
@@ -16,5 +16,10 @@ Gem::Specification.new do |spec|
spec.author = "James Healy"
spec.email = "jimmy@deefa.com"
spec.homepage = "http://github.com/yob/pdf-reader"
+
+ spec.add_development_dependency("rake")
+ spec.add_development_dependency("roodi")
+ spec.add_development_dependency("rspec", "~>2.1")
+
spec.add_dependency('Ascii85', '>=0.9')
end
diff --git a/specs/buffer_spec.rb b/spec/buffer_spec.rb
similarity index 72%
rename from specs/buffer_spec.rb
rename to spec/buffer_spec.rb
index af233cc7..48f1a225 100644
--- a/specs/buffer_spec.rb
+++ b/spec/buffer_spec.rb
@@ -3,32 +3,32 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Buffer, "token method" do
+describe PDF::Reader::Buffer, "token method" do
include BufferHelper
include EncodingHelper
- specify "should return nil when there's no IO left" do
+ it "should return nil when there's no IO left" do
buf = parse_string("aaa")
buf.token
buf.token.should be_nil
end
- specify "should correctly return a simple token - 1" do
+ it "should correctly return a simple token - 1" do
buf = parse_string("aaa")
buf.token.should eql("aaa")
buf.token.should be_nil
end
- specify "should correctly return a simple token - 2" do
+ it "should correctly return a simple token - 2" do
buf = parse_string("1.0")
buf.token.should eql("1.0")
buf.token.should be_nil
end
- specify "should correctly return two simple tokens" do
+ it "should correctly return two simple tokens" do
buf = parse_string("aaa 1.0")
buf.token.should eql("aaa")
@@ -36,7 +36,7 @@
buf.token.should be_nil
end
- specify "should correctly tokenise opening delimiters" do
+ it "should correctly tokenise opening delimiters" do
buf = parse_string("<[{/(")
buf.token.should eql("<")
@@ -49,7 +49,7 @@
buf.token.should be_nil
end
- specify "should correctly tokenise closing delimiters" do
+ it "should correctly tokenise closing delimiters" do
buf = parse_string(")>]}")
buf.token.should eql(")")
@@ -59,7 +59,7 @@
buf.token.should be_nil
end
- specify "should correctly tokenise hash delimiters" do
+ it "should correctly tokenise hash delimiters" do
buf = parse_string("<>")
buf.token.should eql("<<")
@@ -68,7 +68,7 @@
buf.token.should be_nil
end
- specify "should correctly return simple tokens with delimiters" do
+ it "should correctly return simple tokens with delimiters" do
buf = parse_string("")
buf.token.should eql("<")
@@ -80,7 +80,7 @@
buf.token.should be_nil
end
- specify "should correctly return two name tokens" do
+ it "should correctly return two name tokens" do
buf = parse_string("/Type/Pages")
buf.token.should eql("/")
@@ -90,7 +90,7 @@
buf.token.should be_nil
end
- specify "should tokenise a dict correctly" do
+ it "should tokenise a dict correctly" do
buf = parse_string("/Registry (Adobe) /Ordering (Japan1) /Supplement")
buf.token.should eql("/")
buf.token.should eql("Registry")
@@ -106,28 +106,28 @@
buf.token.should eql("Supplement")
end
- specify "should tokenise a string without a % correctly" do
+ it "should tokenise a string without a % correctly" do
buf = parse_string("(James)")
buf.token.should eql("(")
buf.token.should eql("James")
buf.token.should eql(")")
end
- specify "should tokenise a literal string with a % correctly" do
+ it "should tokenise a literal string with a % correctly" do
buf = parse_string("(James%Healy)")
buf.token.should eql("(")
buf.token.should eql("James%Healy")
buf.token.should eql(")")
end
- specify "should tokenise a hex string with a space correctly" do
+ it "should tokenise a hex string with a space correctly" do
buf = parse_string("")
buf.token.should eql("<")
buf.token.should eql("AABB")
buf.token.should eql(">")
end
- specify "should tokenise a string with comments correctly" do
+ it "should tokenise a string with comments correctly" do
buf = parse_string("(James%Healy) % this is a comment\n(")
buf.token.should eql("(")
buf.token.should eql("James%Healy")
@@ -135,20 +135,20 @@
buf.token.should eql("(")
end
- specify "should tokenise a string with comments correctly" do
+ it "should tokenise a string with comments correctly" do
buf = parse_string("James % this is a comment")
buf.token.should eql("James")
buf.token.should be_nil
end
- specify "should tokenise a string with an escaped, unbalanced param correctly" do
+ it "should tokenise a string with an escaped, unbalanced param correctly" do
buf = parse_string("(James \\(Code Monkey)")
buf.token.should eql("(")
buf.token.should eql("James \\(Code Monkey")
buf.token.should eql(")")
end
- specify "should correctly return an indirect reference" do
+ it "should correctly return an indirect reference" do
buf = parse_string("aaa 1 0 R bbb")
buf.token.should eql("aaa")
@@ -157,7 +157,7 @@
buf.token.should be_nil
end
- specify "should correctly return two indirect references" do
+ it "should correctly return two indirect references" do
buf = parse_string("1 0 R 2 0 R")
buf.token.should be_a_kind_of(PDF::Reader::Reference)
@@ -165,7 +165,7 @@
buf.token.should be_nil
end
- specify "should correctly seek to a particular byte of the IO - 1" do
+ it "should correctly seek to a particular byte of the IO - 1" do
str = "aaa bbb ccc"
buf = PDF::Reader::Buffer.new(StringIO.new(str), :seek => 4)
@@ -174,7 +174,7 @@
buf.token.should be_nil
end
- specify "should correctly seek to a particular byte of the IO - 2" do
+ it "should correctly seek to a particular byte of the IO - 2" do
str = "aaa bbb ccc"
buf = PDF::Reader::Buffer.new(StringIO.new(str), :seek => 5)
@@ -183,7 +183,7 @@
buf.token.should be_nil
end
- specify "should correctly return a simple literal string" do
+ it "should correctly return a simple literal string" do
buf = parse_string("(aaa)")
buf.token.should eql("(")
@@ -192,7 +192,7 @@
buf.token.should be_nil
end
- specify "should correctly return an empty literal string" do
+ it "should correctly return an empty literal string" do
buf = parse_string("()")
buf.token.should eql("(")
@@ -200,7 +200,7 @@
buf.token.should be_nil
end
- specify "should correctly return a simple literal string with spaces" do
+ it "should correctly return a simple literal string with spaces" do
buf = parse_string("(aaa bbb)")
buf.token.should eql("(")
@@ -209,7 +209,7 @@
buf.token.should be_nil
end
- specify "should correctly return a simple literal string with nested brackets" do
+ it "should correctly return a simple literal string with nested brackets" do
buf = parse_string("(aaa (bbb))")
buf.token.should eql("(")
@@ -218,7 +218,7 @@
buf.token.should be_nil
end
- specify "should correctly return a literal string with escaped slash followed by a closing brace" do
+ it "should correctly return a literal string with escaped slash followed by a closing brace" do
buf = parse_string("(aaa\x5C\x5C)")
buf.token.should eql("(")
@@ -227,7 +227,7 @@
buf.token.should be_nil
end
- specify "should correctly return a literal string with three slashes followed by a closing brace" do
+ it "should correctly return a literal string with three slashes followed by a closing brace" do
buf = parse_string("(aaa\x5C\x5C\x5C))")
buf.token.should eql("(")
@@ -236,7 +236,7 @@
buf.token.should be_nil
end
- specify "should correctly return a dictionary with embedded hex string" do
+ it "should correctly return a dictionary with embedded hex string" do
buf = parse_string("<< /X <48656C6C6F> >>")
buf.token.should eql("<<")
buf.token.should eql("/")
@@ -246,7 +246,7 @@
buf.token.should eql(">")
buf.token.should eql(">>")
end
- specify "should correctly return a dictionary with embedded hex string" do
+ it "should correctly return a dictionary with embedded hex string" do
buf = parse_string("/Span<>> BDC")
buf.token.should eql("/")
buf.token.should eql("Span")
@@ -260,7 +260,7 @@
buf.token.should eql("BDC")
end
- specify "should correctly return a dictionary with an indirect reference" do
+ it "should correctly return a dictionary with an indirect reference" do
buf = parse_string("<< /X 10 0 R >>")
buf.token.should eql("<<")
buf.token.should eql("/")
@@ -269,7 +269,7 @@
buf.token.should eql(">>")
end
- specify "should correctly return a dictionary with an indirect reference and more than 10 tokens" do
+ it "should correctly return a dictionary with an indirect reference and more than 10 tokens" do
buf = parse_string("<< /X 10 0 R /Y 11 0 R /Z 12 0 R >>")
buf.token.should eql("<<")
buf.token.should eql("/")
@@ -284,7 +284,7 @@
buf.token.should eql(">>")
end
- specify "should record io position" do
+ it "should record io position" do
buf = parse_string("aaa bbb")
buf.pos.should eql(0)
@@ -292,7 +292,7 @@
buf.pos.should eql(7)
end
- specify "should restore io position if it's been changed on us" do
+ it "should restore io position if it's been changed on us" do
io = StringIO.new("aaa bbb")
buf = PDF::Reader::Buffer.new(io)
@@ -306,7 +306,7 @@
buf.pos.should eql(7)
end
- specify "should correctly tokenise an inline image when inside a content stream" do
+ it "should correctly tokenise an inline image when inside a content stream" do
io = StringIO.new("BT ID aaa bbb ccc \xF0\xF0\xF0 EI")
buf = PDF::Reader::Buffer.new(io, :content_stream => true)
@@ -317,7 +317,7 @@
buf.token.should eql("EI")
end
- specify "should correctly tokenise an inline image when outside a content stream" do
+ it "should correctly tokenise an inline image when outside a content stream" do
io = StringIO.new("BT ID aaa bbb ccc \xF0\xF0\xF0 EI")
buf = PDF::Reader::Buffer.new(io, :content_stream => false)
@@ -332,16 +332,16 @@
end
end
-context PDF::Reader::Buffer, "empty? method" do
+describe PDF::Reader::Buffer, "empty? method" do
include BufferHelper
- specify "should correctly return false if there are remaining tokens" do
+ it "should correctly return false if there are remaining tokens" do
buf = parse_string("aaa")
buf.empty?.should be_false
end
- specify "should correctly return true if there are no remaining tokens" do
+ it "should correctly return true if there are no remaining tokens" do
buf = parse_string("aaa")
buf.empty?.should be_false
@@ -350,65 +350,65 @@
end
end
-context PDF::Reader::Buffer, "find_first_xref_offset method" do
+describe PDF::Reader::Buffer, "find_first_xref_offset method" do
- specify "should find the first xref offset from cairo-basic.pdf correctly" do
+ it "should find the first xref offset from cairo-basic.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/cairo-basic.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(9243)
end
- specify "should find the first xref offset from cairo-unicode.pdf correctly" do
+ it "should find the first xref offset from cairo-unicode.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/cairo-unicode.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(136174)
end
- specify "should find the first xref offset from prince1.pdf correctly" do
+ it "should find the first xref offset from prince1.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/prince1.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(678715)
end
- specify "should find the first xref offset from prince2.pdf correctly" do
+ it "should find the first xref offset from prince2.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/prince2.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(941440)
end
- specify "should find the first xref offset from pdfwriter-manual.pdf correctly" do
+ it "should find the first xref offset from pdfwriter-manual.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/pdfwriter-manual.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(275320)
end
- specify "should find the first xref offset from pdf-distiller.pdf correctly" do
+ it "should find the first xref offset from pdf-distiller.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/pdf-distiller.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(173)
end
- specify "should find the first xref offset from pdflatex.pdf correctly" do
+ it "should find the first xref offset from pdflatex.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/pdflatex.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(152898)
end
- specify "should find the first xref offset from openoffice-2.2.pdf correctly" do
+ it "should find the first xref offset from openoffice-2.2.pdf correctly" do
@file = File.new(File.dirname(__FILE__) + "/data/openoffice-2.2.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@buffer.find_first_xref_offset.should eql(36961)
end
- specify "should raise an exception when buffer doesn't contain an EOF marker" do
+ it "should raise an exception when buffer doesn't contain an EOF marker" do
@file = File.new(File.dirname(__FILE__) + "/data/invalid/no_eof.pdf")
@buffer = PDF::Reader::Buffer.new(@file)
@@ -417,24 +417,24 @@
end
-context PDF::Reader::Buffer, "read method" do
+describe PDF::Reader::Buffer, "read method" do
include BufferHelper
- specify "should return raw data from the underlying IO" do
+ it "should return raw data from the underlying IO" do
buf = parse_string("stream bbb")
buf.token.should eql("stream")
buf.read(3).should eql("bbb")
end
- specify "should return raw data from the underlying IO" do
+ it "should return raw data from the underlying IO" do
buf = parse_string("stream\n\nbbb")
buf.token.should eql("stream")
buf.read(4).should eql("\nbbb")
end
- specify "should return raw data from the underlying IO and skip LF/CR bytes" do
+ it "should return raw data from the underlying IO and skip LF/CR bytes" do
buf = parse_string("stream\n\nbbb")
buf.token.should eql("stream")
diff --git a/specs/callback_spec.rb b/spec/callback_spec.rb
similarity index 89%
rename from specs/callback_spec.rb
rename to spec/callback_spec.rb
index d9ae8c76..ea3ea777 100644
--- a/specs/callback_spec.rb
+++ b/spec/callback_spec.rb
@@ -13,14 +13,14 @@
# * All binary strings will be marked as such on M17N aware
#
-context PDF::Reader do
+describe PDF::Reader do
include EncodingHelper
#############################################################################
# Metadata Callbacks
#############################################################################
- context "pdf_version callback" do
+ describe "pdf_version callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single float argument on #{filename}" do
receiver.all_args(:pdf_version).each.each do |args|
@@ -31,7 +31,7 @@
end
end
- context "metadata callback" do
+ describe "metadata callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single hash argument on #{filename}" do
receiver.all_args(:metadata).each.each do |args|
@@ -43,7 +43,7 @@
end
end
- context "xml_metadata callback" do
+ describe "xml_metadata callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single UTF-8 string argument on #{filename}" do
@@ -57,7 +57,7 @@
end
end
- context "page_count callback" do
+ describe "page_count callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single Fixnum argument that is > 0 on #{filename}" do
@@ -75,7 +75,7 @@
# Page Callbacks
#############################################################################
- context "begin_inline_image callback" do
+ describe "begin_inline_image callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:begin_inline_image).each do |args|
@@ -85,7 +85,7 @@
end
end
- context "begin_inline_image_data callback" do
+ describe "begin_inline_image_data callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a Hash and binary string argument on #{filename}" do
receiver.all_args(:begin_inline_image_data).each do |args|
@@ -116,7 +116,7 @@
end
end
- context "begin_text_object callback" do
+ describe "begin_text_object callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:begin_text_object).each do |args|
@@ -126,7 +126,7 @@
end
end
- context "end_document callback" do
+ describe "end_document callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:end_document).each do |args|
@@ -136,7 +136,7 @@
end
end
- context "end_inline_image callback" do
+ describe "end_inline_image callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
@@ -148,7 +148,7 @@
end
end
- context "end_page callback" do
+ describe "end_page callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:end_page).each do |args|
@@ -158,7 +158,7 @@
end
end
- context "end_page_container callback" do
+ describe "end_page_container callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:end_page_container).each do |args|
@@ -168,7 +168,7 @@
end
end
- context "end_text_object callback" do
+ describe "end_text_object callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:end_text_object).each do |args|
@@ -178,7 +178,7 @@
end
end
- context "move_to_next_line_and_show_text callback" do
+ describe "move_to_next_line_and_show_text callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single UTF-8 strings on #{filename}" do
receiver.all_args(:move_to_next_line_and_show_text).each do |args|
@@ -190,7 +190,7 @@
end
end
- context "restore_graphics_state callback" do
+ describe "restore_graphics_state callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:restore_graphics_state).each do |args|
@@ -200,7 +200,7 @@
end
end
- context "save_graphics_state callback" do
+ describe "save_graphics_state callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:save_graphics_state).each do |args|
@@ -210,7 +210,7 @@
end
end
- context "set_text_font_and_size callback" do
+ describe "set_text_font_and_size callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return no arguments on #{filename}" do
receiver.all_args(:set_text_font_and_size).each do |args|
@@ -222,7 +222,7 @@
end
end
- context "show_text callback" do
+ describe "show_text callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single UTF-8 string argument on #{filename}" do
receiver.all_args(:show_text).each do |args|
@@ -234,7 +234,7 @@
end
end
- context "show_text_with_positioning callback" do
+ describe "show_text_with_positioning callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return an array of Numbers and UTF-8 strings on #{filename}" do
receiver.all_args(:show_text_with_positioning).each do |args|
@@ -247,7 +247,7 @@
end
end
- context "set_spacing_next_line_show_text callback" do
+ describe "set_spacing_next_line_show_text callback" do
CallbackHelper.instance.good_receivers.each do |filename, receiver|
it "should return a single UTF-8 strings on #{filename}" do
receiver.all_args(:set_spacing_next_line_show_text).each do |args|
diff --git a/specs/cmap_spec.rb b/spec/cmap_spec.rb
similarity index 80%
rename from specs/cmap_spec.rb
rename to spec/cmap_spec.rb
index ec2d8626..eb53572d 100644
--- a/specs/cmap_spec.rb
+++ b/spec/cmap_spec.rb
@@ -7,9 +7,9 @@ class PDF::Reader::CMap
attr_reader :map
end
-context "PDF::Reader::CMap with a bfchar cmap" do
+describe "PDF::Reader::CMap with a bfchar cmap" do
- specify "should correctly load a cmap object string" do
+ it "should correctly load a cmap object string" do
filename = File.dirname(__FILE__) + "/data/cmap_with_bfchar.txt"
map = PDF::Reader::CMap.new(File.read(filename))
map.map.should be_a_kind_of(Hash)
@@ -19,7 +19,7 @@ class PDF::Reader::CMap
map.map[0x9].should eql(0x73)
end
- specify "should correctly convert a character code into a unicode codepoint" do
+ it "should correctly convert a character code into a unicode codepoint" do
filename = File.dirname(__FILE__) + "/data/cmap_with_bfchar.txt"
map = PDF::Reader::CMap.new(File.read(filename))
map.decode(0x1).should eql(0x48)
@@ -27,7 +27,7 @@ class PDF::Reader::CMap
map.decode(0x9).should eql(0x73)
end
- specify "should correctly load a cmap that uses the beginbfrange operator" do
+ it "should correctly load a cmap that uses the beginbfrange operator" do
filename = File.dirname(__FILE__) + "/data/cmap_with_bfrange.txt"
map = PDF::Reader::CMap.new(File.read(filename))
map.decode(0x16C9).should eql(0x4F38) # mapped with the bfchar operator
@@ -36,13 +36,13 @@ class PDF::Reader::CMap
map.decode(0x0005).should eql(0x0020+2) # mapped with the bfrange operator
end
- specify "should correctly load a cmap that uses the beginbfrange operator" do
+ it "should correctly load a cmap that uses the beginbfrange operator" do
filename = File.dirname(__FILE__) + "/data/cmap_with_bfrange_two.txt"
map = PDF::Reader::CMap.new(File.read(filename))
map.decode(0x0100).should eql(0x0100) # mapped with the bfrange operator
end
- specify "should correctly load a cmap that uses the beginbfrange operator with the array syntax" do
+ it "should correctly load a cmap that uses the beginbfrange operator with the array syntax" do
filename = File.dirname(__FILE__) + "/data/cmap_with_bfrange_three.txt"
map = PDF::Reader::CMap.new(File.read(filename))
diff --git a/specs/data/20070313 - 2nd Laptop Battery.pdf b/spec/data/20070313 - 2nd Laptop Battery.pdf
similarity index 100%
rename from specs/data/20070313 - 2nd Laptop Battery.pdf
rename to spec/data/20070313 - 2nd Laptop Battery.pdf
diff --git a/specs/data/adobe_sample.pdf b/spec/data/adobe_sample.pdf
similarity index 100%
rename from specs/data/adobe_sample.pdf
rename to spec/data/adobe_sample.pdf
diff --git a/specs/data/ascii85_filter.pdf b/spec/data/ascii85_filter.pdf
similarity index 100%
rename from specs/data/ascii85_filter.pdf
rename to spec/data/ascii85_filter.pdf
diff --git a/specs/data/broken_string.pdf b/spec/data/broken_string.pdf
similarity index 100%
rename from specs/data/broken_string.pdf
rename to spec/data/broken_string.pdf
diff --git a/specs/data/cairo-basic.pdf b/spec/data/cairo-basic.pdf
similarity index 100%
rename from specs/data/cairo-basic.pdf
rename to spec/data/cairo-basic.pdf
diff --git a/specs/data/cairo-unicode-short.pdf b/spec/data/cairo-unicode-short.pdf
similarity index 100%
rename from specs/data/cairo-unicode-short.pdf
rename to spec/data/cairo-unicode-short.pdf
diff --git a/specs/data/cairo-unicode.pdf b/spec/data/cairo-unicode.pdf
similarity index 100%
rename from specs/data/cairo-unicode.pdf
rename to spec/data/cairo-unicode.pdf
diff --git a/specs/data/cmap_with_bfchar.txt b/spec/data/cmap_with_bfchar.txt
similarity index 100%
rename from specs/data/cmap_with_bfchar.txt
rename to spec/data/cmap_with_bfchar.txt
diff --git a/specs/data/cmap_with_bfrange.txt b/spec/data/cmap_with_bfrange.txt
similarity index 100%
rename from specs/data/cmap_with_bfrange.txt
rename to spec/data/cmap_with_bfrange.txt
diff --git a/specs/data/cmap_with_bfrange_three.txt b/spec/data/cmap_with_bfrange_three.txt
similarity index 100%
rename from specs/data/cmap_with_bfrange_three.txt
rename to spec/data/cmap_with_bfrange_three.txt
diff --git a/specs/data/cmap_with_bfrange_two.txt b/spec/data/cmap_with_bfrange_two.txt
similarity index 100%
rename from specs/data/cmap_with_bfrange_two.txt
rename to spec/data/cmap_with_bfrange_two.txt
diff --git a/specs/data/content_stream_missing_final_operator.pdf b/spec/data/content_stream_missing_final_operator.pdf
similarity index 100%
rename from specs/data/content_stream_missing_final_operator.pdf
rename to spec/data/content_stream_missing_final_operator.pdf
diff --git a/specs/data/content_stream_refers_to_invalid_font.pdf b/spec/data/content_stream_refers_to_invalid_font.pdf
similarity index 100%
rename from specs/data/content_stream_refers_to_invalid_font.pdf
rename to spec/data/content_stream_refers_to_invalid_font.pdf
diff --git a/specs/data/content_stream_trailing_whitespace.pdf b/spec/data/content_stream_trailing_whitespace.pdf
similarity index 100%
rename from specs/data/content_stream_trailing_whitespace.pdf
rename to spec/data/content_stream_trailing_whitespace.pdf
diff --git a/specs/data/content_stream_with_length_as_ref.pdf b/spec/data/content_stream_with_length_as_ref.pdf
similarity index 100%
rename from specs/data/content_stream_with_length_as_ref.pdf
rename to spec/data/content_stream_with_length_as_ref.pdf
diff --git a/specs/data/content_stream_with_length_as_ref_and_windows_breaks.pdf b/spec/data/content_stream_with_length_as_ref_and_windows_breaks.pdf
similarity index 100%
rename from specs/data/content_stream_with_length_as_ref_and_windows_breaks.pdf
rename to spec/data/content_stream_with_length_as_ref_and_windows_breaks.pdf
diff --git a/specs/data/cross_ref_stream.pdf b/spec/data/cross_ref_stream.pdf
similarity index 100%
rename from specs/data/cross_ref_stream.pdf
rename to spec/data/cross_ref_stream.pdf
diff --git a/specs/data/deflated_with_predictors.dat b/spec/data/deflated_with_predictors.dat
similarity index 100%
rename from specs/data/deflated_with_predictors.dat
rename to spec/data/deflated_with_predictors.dat
diff --git a/specs/data/deflated_with_predictors_result.dat b/spec/data/deflated_with_predictors_result.dat
similarity index 100%
rename from specs/data/deflated_with_predictors_result.dat
rename to spec/data/deflated_with_predictors_result.dat
diff --git a/specs/data/difference_table.pdf b/spec/data/difference_table.pdf
similarity index 100%
rename from specs/data/difference_table.pdf
rename to spec/data/difference_table.pdf
diff --git a/specs/data/difference_table_encrypted.pdf b/spec/data/difference_table_encrypted.pdf
similarity index 100%
rename from specs/data/difference_table_encrypted.pdf
rename to spec/data/difference_table_encrypted.pdf
diff --git a/specs/data/distiller_unicode.pdf b/spec/data/distiller_unicode.pdf
similarity index 100%
rename from specs/data/distiller_unicode.pdf
rename to spec/data/distiller_unicode.pdf
diff --git a/specs/data/dutch.pdf b/spec/data/dutch.pdf
similarity index 100%
rename from specs/data/dutch.pdf
rename to spec/data/dutch.pdf
diff --git a/specs/data/form_xobject.pdf b/spec/data/form_xobject.pdf
similarity index 100%
rename from specs/data/form_xobject.pdf
rename to spec/data/form_xobject.pdf
diff --git a/specs/data/form_xobject_more.pdf b/spec/data/form_xobject_more.pdf
similarity index 100%
rename from specs/data/form_xobject_more.pdf
rename to spec/data/form_xobject_more.pdf
diff --git a/specs/data/hard_lock_under_osx.pdf b/spec/data/hard_lock_under_osx.pdf
similarity index 100%
rename from specs/data/hard_lock_under_osx.pdf
rename to spec/data/hard_lock_under_osx.pdf
diff --git a/specs/data/indirect_xobject.pdf b/spec/data/indirect_xobject.pdf
similarity index 100%
rename from specs/data/indirect_xobject.pdf
rename to spec/data/indirect_xobject.pdf
diff --git a/specs/data/inline_image.pdf b/spec/data/inline_image.pdf
similarity index 100%
rename from specs/data/inline_image.pdf
rename to spec/data/inline_image.pdf
diff --git a/specs/data/inline_image_single_line_content_stream.pdf b/spec/data/inline_image_single_line_content_stream.pdf
similarity index 100%
rename from specs/data/inline_image_single_line_content_stream.pdf
rename to spec/data/inline_image_single_line_content_stream.pdf
diff --git a/specs/data/invalid/data.csv b/spec/data/invalid/data.csv
similarity index 100%
rename from specs/data/invalid/data.csv
rename to spec/data/invalid/data.csv
diff --git a/specs/data/invalid/linearized_bad_xref_offset.pdf b/spec/data/invalid/linearized_bad_xref_offset.pdf
similarity index 100%
rename from specs/data/invalid/linearized_bad_xref_offset.pdf
rename to spec/data/invalid/linearized_bad_xref_offset.pdf
diff --git a/specs/data/invalid/no_eof.pdf b/spec/data/invalid/no_eof.pdf
similarity index 100%
rename from specs/data/invalid/no_eof.pdf
rename to spec/data/invalid/no_eof.pdf
diff --git a/specs/data/invalid/no_trailer.pdf b/spec/data/invalid/no_trailer.pdf
similarity index 100%
rename from specs/data/invalid/no_trailer.pdf
rename to spec/data/invalid/no_trailer.pdf
diff --git a/specs/data/invalid/trailer_is_not_a_dict.pdf b/spec/data/invalid/trailer_is_not_a_dict.pdf
similarity index 100%
rename from specs/data/invalid/trailer_is_not_a_dict.pdf
rename to spec/data/invalid/trailer_is_not_a_dict.pdf
diff --git a/specs/data/large_single_line_content_stream.pdf b/spec/data/large_single_line_content_stream.pdf
similarity index 100%
rename from specs/data/large_single_line_content_stream.pdf
rename to spec/data/large_single_line_content_stream.pdf
diff --git a/specs/data/lzw_compressed.dat b/spec/data/lzw_compressed.dat
similarity index 100%
rename from specs/data/lzw_compressed.dat
rename to spec/data/lzw_compressed.dat
diff --git a/specs/data/lzw_decompressed.dat b/spec/data/lzw_decompressed.dat
similarity index 100%
rename from specs/data/lzw_decompressed.dat
rename to spec/data/lzw_decompressed.dat
diff --git a/specs/data/lzw_stream.pdf b/spec/data/lzw_stream.pdf
similarity index 100%
rename from specs/data/lzw_stream.pdf
rename to spec/data/lzw_stream.pdf
diff --git a/specs/data/no_text_spaces.pdf b/spec/data/no_text_spaces.pdf
similarity index 100%
rename from specs/data/no_text_spaces.pdf
rename to spec/data/no_text_spaces.pdf
diff --git a/specs/data/oo3.pdf b/spec/data/oo3.pdf
similarity index 100%
rename from specs/data/oo3.pdf
rename to spec/data/oo3.pdf
diff --git a/specs/data/openoffice-2.2.pdf b/spec/data/openoffice-2.2.pdf
similarity index 100%
rename from specs/data/openoffice-2.2.pdf
rename to spec/data/openoffice-2.2.pdf
diff --git a/specs/data/osx_print_unicode.pdf b/spec/data/osx_print_unicode.pdf
similarity index 100%
rename from specs/data/osx_print_unicode.pdf
rename to spec/data/osx_print_unicode.pdf
diff --git a/specs/data/pdf-distiller.pdf b/spec/data/pdf-distiller.pdf
similarity index 100%
rename from specs/data/pdf-distiller.pdf
rename to spec/data/pdf-distiller.pdf
diff --git a/specs/data/pdflatex.pdf b/spec/data/pdflatex.pdf
similarity index 100%
rename from specs/data/pdflatex.pdf
rename to spec/data/pdflatex.pdf
diff --git a/specs/data/pdfwriter-manual.pdf b/spec/data/pdfwriter-manual.pdf
similarity index 100%
rename from specs/data/pdfwriter-manual.pdf
rename to spec/data/pdfwriter-manual.pdf
diff --git a/specs/data/prince1.pdf b/spec/data/prince1.pdf
similarity index 100%
rename from specs/data/prince1.pdf
rename to spec/data/prince1.pdf
diff --git a/specs/data/prince2.pdf b/spec/data/prince2.pdf
similarity index 100%
rename from specs/data/prince2.pdf
rename to spec/data/prince2.pdf
diff --git a/specs/data/screwey_xref_offsets.pdf b/spec/data/screwey_xref_offsets.pdf
similarity index 100%
rename from specs/data/screwey_xref_offsets.pdf
rename to spec/data/screwey_xref_offsets.pdf
diff --git a/specs/data/space_after_eof.pdf b/spec/data/space_after_eof.pdf
similarity index 100%
rename from specs/data/space_after_eof.pdf
rename to spec/data/space_after_eof.pdf
diff --git a/specs/data/split_params_and_operator.pdf b/spec/data/split_params_and_operator.pdf
similarity index 100%
rename from specs/data/split_params_and_operator.pdf
rename to spec/data/split_params_and_operator.pdf
diff --git a/specs/data/xref_subsections.pdf b/spec/data/xref_subsections.pdf
similarity index 100%
rename from specs/data/xref_subsections.pdf
rename to spec/data/xref_subsections.pdf
diff --git a/specs/data/zlib_stream_issue.pdf b/spec/data/zlib_stream_issue.pdf
similarity index 100%
rename from specs/data/zlib_stream_issue.pdf
rename to spec/data/zlib_stream_issue.pdf
diff --git a/specs/encoding_spec.rb b/spec/encoding_spec.rb
similarity index 79%
rename from specs/encoding_spec.rb
rename to spec/encoding_spec.rb
index d29694de..2a39a1d9 100644
--- a/specs/encoding_spec.rb
+++ b/spec/encoding_spec.rb
@@ -3,21 +3,21 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Encoding do
+describe PDF::Reader::Encoding do
- specify "should return a new encoding object on request, or raise an error if unrecognised" do
+ it "should return a new encoding object on request, or raise an error if unrecognised" do
lambda { PDF::Reader::Encoding.new("FakeEncoding")}.should raise_error(PDF::Reader::UnsupportedFeatureError)
PDF::Reader::Encoding.new(nil).should be_a_kind_of(PDF::Reader::Encoding)
end
- specify "should return a new encoding object on request, or raise an error if unrecognised" do
+ it "should return a new encoding object on request, or raise an error if unrecognised" do
win = {:Encoding => :WinAnsiEncoding}
fake = {:Encoding => :FakeEncoding}
PDF::Reader::Encoding.new(win).should be_a_kind_of(PDF::Reader::Encoding)
lambda { PDF::Reader::Encoding.new(fake)}.should raise_error(PDF::Reader::UnsupportedFeatureError)
end
- specify "should return a new encoding object with a differences table on request" do
+ it "should return a new encoding object with a differences table on request" do
win = {
:Encoding => :WinAnsiEncoding,
:Differences => [25, :A, 26, :B]
@@ -29,7 +29,7 @@
enc.differences[26].should eql(:B)
end
- specify "should return a new encoding object with a differences table on request" do
+ it "should return a new encoding object with a differences table on request" do
win = {
:Encoding => :WinAnsiEncoding,
:Differences => [25, :A, :B]
@@ -41,7 +41,7 @@
enc.differences[26].should eql(:B)
end
- specify "should correctly replace control characters with 'unknown char' when there's no applicable difference table entry" do
+ it "should correctly replace control characters with 'unknown char' when there's no applicable difference table entry" do
win = {
:Encoding => :WinAnsiEncoding,
:Differences => [1, :A,]
@@ -51,9 +51,9 @@
end
end
-context "The PDF::Reader::Encoding::IdentityH class" do
+describe "The PDF::Reader::Encoding::IdentityH class" do
- specify "should return utf-8 squares if to_utf8 is called without a cmap" do
+ it "should return utf-8 squares if to_utf8 is called without a cmap" do
e = PDF::Reader::Encoding.new("Identity-H")
[
{:expert => "\x22", :utf8 => ""},
@@ -71,7 +71,7 @@
end
end
- specify "should convert an IdentityH encoded string into UTF-8" do
+ it "should convert an IdentityH encoded string into UTF-8" do
e = PDF::Reader::Encoding.new("Identity-H")
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -86,9 +86,9 @@
end
-context "The PDF::Reader::Encoding::MacExpertEncoding class" do
+describe "The PDF::Reader::Encoding::MacExpertEncoding class" do
- specify "should correctly convert various expert strings to utf-8" do
+ it "should correctly convert various expert strings to utf-8" do
e = PDF::Reader::Encoding.new(:MacExpertEncoding)
[
{:expert => "\x22", :utf8 => [0xF6F8].pack("U*")},
@@ -107,7 +107,7 @@
end
end
- specify "should correctly convert various mac expert strings when a differences table is specified" do
+ it "should correctly convert various mac expert strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:MacExpertEncoding)
e.differences = [0xEE, :A]
[
@@ -126,7 +126,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:MacExpertEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -141,9 +141,9 @@
end
end
-context "The PDF::Reader::Encoding::MacRomanEncoding class" do
+describe "The PDF::Reader::Encoding::MacRomanEncoding class" do
- specify "should correctly convert various mac roman strings to utf-8" do
+ it "should correctly convert various mac roman strings to utf-8" do
e = PDF::Reader::Encoding.new(:MacRomanEncoding)
[
{:mac => "abc", :utf8 => "abc"},
@@ -164,7 +164,7 @@
end
end
- specify "should correctly convert various mac roman strings when a differences table is specified" do
+ it "should correctly convert various mac roman strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:MacRomanEncoding)
e.differences = [0xEE, :A]
[
@@ -183,7 +183,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:MacRomanEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -198,9 +198,9 @@
end
end
-context "The PDF::Reader::Encoding::PDFDocEncoding class" do
+describe "The PDF::Reader::Encoding::PDFDocEncoding class" do
- specify "should correctly convert various PDFDoc strings to utf-8" do
+ it "should correctly convert various PDFDoc strings to utf-8" do
e = PDF::Reader::Encoding.new(:PDFDocEncoding)
[
{:pdf => "\x22", :utf8 => [0x22].pack("U*")},
@@ -219,7 +219,7 @@
end
end
- specify "should correctly convert various pdf doc strings when a differences table is specified" do
+ it "should correctly convert various pdf doc strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:PDFDocEncoding)
e.differences = [0xEE, :A]
[
@@ -238,7 +238,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:PDFDocEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -253,9 +253,9 @@
end
end
-context "The PDF::Reader::Encoding::StandardEncoding class" do
+describe "The PDF::Reader::Encoding::StandardEncoding class" do
- specify "should correctly convert various standard strings to utf-8" do
+ it "should correctly convert various standard strings to utf-8" do
e = PDF::Reader::Encoding.new(:StandardEncoding)
[
{:standard => "abc", :utf8 => "abc"},
@@ -278,7 +278,7 @@
end
end
- specify "should correctly convert various standard strings when a differences table is specified" do
+ it "should correctly convert various standard strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:StandardEncoding)
e.differences = [0xEE, :A]
[
@@ -297,7 +297,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:StandardEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -312,9 +312,9 @@
end
end
-context "The PDF::Reader::Encoding::SymbolEncoding class" do
+describe "The PDF::Reader::Encoding::SymbolEncoding class" do
- specify "should correctly convert various symbol strings to utf-8" do
+ it "should correctly convert various symbol strings to utf-8" do
e = PDF::Reader::Encoding.new(:SymbolEncoding)
[
{:symbol => "\x41", :utf8 => [0x0391].pack("U*")}, # alpha
@@ -335,7 +335,7 @@
end
end
- specify "should correctly convert various symbol strings when a differences table is specified" do
+ it "should correctly convert various symbol strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:SymbolEncoding)
e.differences = [0xEE, :A]
[
@@ -354,7 +354,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:SymbolEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -369,9 +369,9 @@
end
end
-context "The PDF::Reader::Encoding::WinAnsiEncoding class" do
+describe "The PDF::Reader::Encoding::WinAnsiEncoding class" do
- specify "should correctly convert various win-1252 strings to utf-8" do
+ it "should correctly convert various win-1252 strings to utf-8" do
e = PDF::Reader::Encoding.new(:WinAnsiEncoding)
[
{:win => "abc", :utf8 => "abc"},
@@ -392,7 +392,7 @@
end
end
- specify "should correctly convert various win-1252 strings when a differences table is specified" do
+ it "should correctly convert various win-1252 strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:WinAnsiEncoding)
e.differences = [0xEE, :A]
[
@@ -410,7 +410,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:WinAnsiEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -425,9 +425,9 @@
end
end
-context "The PDF::Reader::Encoding::ZapfDingbatsEncoding class" do
+describe "The PDF::Reader::Encoding::ZapfDingbatsEncoding class" do
- specify "should correctly convert various dingbats strings to utf-8" do
+ it "should correctly convert various dingbats strings to utf-8" do
e = PDF::Reader::Encoding.new(:ZapfDingbatsEncoding)
[
{:dingbats => "\x22", :utf8 => [0x2702].pack("U*")}, # scissors
@@ -447,7 +447,7 @@
end
end
- specify "should correctly convert various dingbats strings when a differences table is specified" do
+ it "should correctly convert various dingbats strings when a differences table is specified" do
e = PDF::Reader::Encoding.new(:ZapfDingbatsEncoding)
e.differences = [0xEE, :A]
[
@@ -466,7 +466,7 @@
end
end
- specify "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
+ it "should correctly convert a string into utf-8 when a ToUnicode CMap is provided" do
e = PDF::Reader::Encoding.new(:ZapfDingbatsEncoding)
cmap = PDF::Reader::CMap.new("")
cmap.instance_variable_set("@map",{1 => 0x20AC, 2 => 0x0031})
@@ -481,9 +481,9 @@
end
end
-context "The PDF::Reader::Encoding::UTF16Encoding class" do
+describe "The PDF::Reader::Encoding::UTF16Encoding class" do
- specify "should correctly convert various PDFDoc strings to utf-8" do
+ it "should correctly convert various PDFDoc strings to utf-8" do
e = PDF::Reader::Encoding.new(:UTF16Encoding)
[
{:utf16 => "\x00\x41", :utf8 => [0x41].pack("U*")},
diff --git a/specs/filter_spec.rb b/spec/filter_spec.rb
similarity index 77%
rename from specs/filter_spec.rb
rename to spec/filter_spec.rb
index a2540eea..600a2a30 100644
--- a/specs/filter_spec.rb
+++ b/spec/filter_spec.rb
@@ -3,11 +3,11 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Filter do
+describe PDF::Reader::Filter do
- specify "should inflate a RFC1950 (zlib) deflated stream correctly"
- specify "should inflate a raw RFC1951 deflated stream correctly"
- specify "should inflate a deflated stream with predictors correctly" do
+ it "should inflate a RFC1950 (zlib) deflated stream correctly"
+ it "should inflate a raw RFC1951 deflated stream correctly"
+ it "should inflate a deflated stream with predictors correctly" do
filter = PDF::Reader::Filter.new(:FlateDecode, :Columns => 5, :Predictor => 12)
if File.respond_to?(:binread)
deflated_data = File.binread(File.dirname(__FILE__) + "/data/deflated_with_predictors.dat")
@@ -19,7 +19,7 @@
filter.filter(deflated_data).should eql(depredicted_data)
end
- specify "should filter a lzw stream with no predictors correctly" do
+ it "should filter a lzw stream with no predictors correctly" do
filter = PDF::Reader::Filter.new(:LZWDecode)
if File.respond_to?(:binread)
compressed_data = File.binread(File.dirname(__FILE__) + "/data/lzw_compressed.dat")
@@ -31,7 +31,7 @@
filter.filter(compressed_data).should eql(decompressed_data)
end
- specify "should raise an exception on LZW compressed streams that use predictors" do
+ it "should raise an exception on LZW compressed streams that use predictors" do
if File.respond_to?(:binread)
compressed_data = File.binread(File.dirname(__FILE__) + "/data/lzw_compressed.dat")
else
@@ -44,31 +44,31 @@
}.should raise_error(PDF::Reader::UnsupportedFeatureError)
end
- specify "should filter a ASCII85 stream correctly" do
+ it "should filter a ASCII85 stream correctly" do
filter = PDF::Reader::Filter.new(:ASCII85Decode)
encoded_data = Ascii85::encode("Ruby")
filter.filter(encoded_data).should eql("Ruby")
end
- specify "should filter a ASCII85 stream missing <~ correctly" do
+ it "should filter a ASCII85 stream missing <~ correctly" do
filter = PDF::Reader::Filter.new(:ASCII85Decode)
encoded_data = Ascii85::encode("Ruby")[2,100]
filter.filter(encoded_data).should eql("Ruby")
end
- specify "should filter a ASCIIHex stream correctly" do
+ it "should filter a ASCIIHex stream correctly" do
filter = PDF::Reader::Filter.new(:ASCIIHexDecode)
encoded_data = "<52756279>"
filter.filter(encoded_data).should eql("Ruby")
end
- specify "should filter a ASCIIHex stream missing delimiters" do
+ it "should filter a ASCIIHex stream missing delimiters" do
filter = PDF::Reader::Filter.new(:ASCIIHexDecode)
encoded_data = "52756279"
filter.filter(encoded_data).should eql("Ruby")
end
- specify "should filter a ASCIIHex stream with an odd number of nibbles" do
+ it "should filter a ASCIIHex stream with an odd number of nibbles" do
filter = PDF::Reader::Filter.new(:ASCIIHexDecode)
encoded_data = "5275627"
filter.filter(encoded_data).should eql("Rubp")
diff --git a/specs/font_spec.rb b/spec/font_spec.rb
similarity index 70%
rename from specs/font_spec.rb
rename to spec/font_spec.rb
index 39564d14..8aaa0e80 100644
--- a/specs/font_spec.rb
+++ b/spec/font_spec.rb
@@ -3,9 +3,9 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Font do
+describe PDF::Reader::Font do
- specify "should select a sensible encoding when set to a symbol font" do
+ it "should select a sensible encoding when set to a symbol font" do
f = PDF::Reader::Font.new
f.basefont = "Arial"
f.encoding.should be_nil
@@ -17,7 +17,7 @@
f.encoding.should be_a_kind_of(PDF::Reader::Encoding)
end
- specify "should correctly create a mapping of glyph names to unicode code points" do
+ it "should correctly create a mapping of glyph names to unicode code points" do
map = PDF::Reader::Font.glyphnames
map.should be_a_kind_of(Hash)
map[:a].should eql(0x0061)
@@ -27,25 +27,25 @@
map[:zukatakana].should eql(0x30BA)
end
- specify "should correctly attempt to convert various strings to utf-8" do
+ it "should correctly attempt to convert various strings to utf-8" do
f = PDF::Reader::Font.new
# TODO: create a mock encoding object and ensure to_utf8 is called on it
end
- specify "should return the same type when to_utf8 is called" do
+ it "should return the same type when to_utf8 is called" do
f = PDF::Reader::Font.new
f.to_utf8("abc").should be_a_kind_of(String)
f.to_utf8(["abc"]).should be_a_kind_of(Array)
f.to_utf8(123).should be_a_kind_of(Numeric)
end
- specify "should use an encoding of StandardEncoding if none has been specified" do
+ it "should use an encoding of StandardEncoding if none has been specified" do
f = PDF::Reader::Font.new
str = "abc\xA8"
f.to_utf8(str).should eql("abc\xC2\xA4")
end
- specify "should correctly store the font BaseFont" do
+ it "should correctly store the font BaseFont" do
f = PDF::Reader::Font.new
f.basefont = :Helvetica
f.basefont.should eql(:Helvetica)
diff --git a/specs/lzw_spec.rb b/spec/lzw_spec.rb
similarity index 92%
rename from specs/lzw_spec.rb
rename to spec/lzw_spec.rb
index d5161fd8..335c3e2f 100644
--- a/specs/lzw_spec.rb
+++ b/spec/lzw_spec.rb
@@ -3,7 +3,7 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::LZW do
+describe PDF::Reader::LZW do
it "should correctly decode a lzw compress string" do
content = %w{ 80 0B 60 50 22 0C 0C 85 01 }.map { |byte|
byte.to_i(16)
diff --git a/specs/meta_spec.rb b/spec/meta_spec.rb
similarity index 80%
rename from specs/meta_spec.rb
rename to spec/meta_spec.rb
index fe07c99b..68a035aa 100644
--- a/specs/meta_spec.rb
+++ b/spec/meta_spec.rb
@@ -40,9 +40,9 @@ def show_text_with_positioning(*params)
end
-context PDF::Reader, "meta specs" do
+describe PDF::Reader, "meta specs" do
- specify "should interpret unicode strings correctly" do
+ it "should interpret unicode strings correctly" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/cairo-unicode-short.pdf", receiver)
@@ -51,7 +51,7 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql("Chunky Bacon")
end
- specify "should process text from a the adobe sample file correctly" do
+ it "should process text from a the adobe sample file correctly" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/adobe_sample.pdf", receiver)
@@ -60,7 +60,7 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql("This is a sample PDF file.If you can read this,you already have Adobe AcrobatReader installed on your computer.")
end
- specify "should process text from a dutch PDF correctly" do
+ it "should process text from a dutch PDF correctly" do
receiver = PageTextReceiver.new
str1 = "Dit\302\240is\302\240een\302\240pdf\302\240test\302\240van\302\240drie\302\240pagina’s."
str2 = "Pagina\302\2401"
@@ -72,7 +72,7 @@ def show_text_with_positioning(*params)
receiver.content[0].include?(str2).should be_true
end
- specify "should process text from a PDF with a difference table correctly" do
+ it "should process text from a PDF with a difference table correctly" do
receiver = PageTextReceiver.new
str = "Goiás"
PDF::Reader.file(File.dirname(__FILE__) + "/data/difference_table.pdf", receiver)
@@ -82,7 +82,7 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql(str)
end
- specify "should process text from a PDF with a content stream that has trailing whitespace" do
+ it "should process text from a PDF with a content stream that has trailing whitespace" do
receiver = PageTextReceiver.new
str = "TaxInvoice"
PDF::Reader.file(File.dirname(__FILE__) + "/data/content_stream_trailing_whitespace.pdf", receiver)
@@ -92,7 +92,7 @@ def show_text_with_positioning(*params)
receiver.content[0].slice(0,10).should eql(str)
end
- specify "should correctly process a PDF with a content stream that is missing an operator (has hanging params)" do
+ it "should correctly process a PDF with a content stream that is missing an operator (has hanging params)" do
receiver = PageTextReceiver.new
str1 = "Locatrix"
str2 = "Ubuntu"
@@ -104,7 +104,7 @@ def show_text_with_positioning(*params)
receiver.content[1].slice(0,6).should eql(str2)
end
- specify "should correctly process a PDF with a string containing a high byte (D1) under MacRomanEncoding" do
+ it "should correctly process a PDF with a string containing a high byte (D1) under MacRomanEncoding" do
# this spec is to detect an hard lock issue some people were encountering on some OSX
# systems. Real pain to debug.
receiver = PageTextReceiver.new
@@ -115,7 +115,7 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql("’")
end
- specify "should not hang when processing a PDF that has a content stream with a broken string" do
+ it "should not hang when processing a PDF that has a content stream with a broken string" do
receiver = PageTextReceiver.new
# this file used to get us into a hard, endless loop. Make sure that doesn't still happen
@@ -126,7 +126,7 @@ def show_text_with_positioning(*params)
end
end
- specify "should correctly process a PDF with a stream that has its length specified as an indirect reference" do
+ it "should correctly process a PDF with a stream that has its length specified as an indirect reference" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/content_stream_with_length_as_ref.pdf", receiver)
@@ -138,7 +138,7 @@ def show_text_with_positioning(*params)
# PDF::Reader::XRef#object was saving an incorrect position when seeking. We
# were saving the current pos of the underlying IO stream, then seeking back
# to it. This was fine, except when there was still content in the buffer.
- specify "should correctly process a PDF with a stream that has its length specified as an indirect reference and uses windows line breaks" do
+ it "should correctly process a PDF with a stream that has its length specified as an indirect reference and uses windows line breaks" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/content_stream_with_length_as_ref_and_windows_breaks.pdf", receiver)
@@ -147,14 +147,14 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql("HelloWorld")
end
- specify "should raise an exception if a content stream refers to a non-existant font" do
+ it "should raise an exception if a content stream refers to a non-existant font" do
receiver = PageTextReceiver.new
lambda {
PDF::Reader.file(File.dirname(__FILE__) + "/data/content_stream_refers_to_invalid_font.pdf", receiver)
}.should raise_error(PDF::Reader::MalformedPDFError)
end
- specify "should correctly process a PDF that uses an ASCII85Decode filter" do
+ it "should correctly process a PDF that uses an ASCII85Decode filter" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/ascii85_filter.pdf", receiver)
@@ -163,7 +163,7 @@ def show_text_with_positioning(*params)
receiver.content[0][0,19].should eql("Et Iunia sexagesimo")
end
- specify "should correctly process a PDF that has an inline image in a content stream with no line breaks" do
+ it "should correctly process a PDF that has an inline image in a content stream with no line breaks" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/inline_image_single_line_content_stream.pdf", receiver)
@@ -172,7 +172,7 @@ def show_text_with_positioning(*params)
receiver.content[0][0,7].should eql("WORKING")
end
- specify "should correctly process a PDF that uses Form XObjects to repeat content" do
+ it "should correctly process a PDF that uses Form XObjects to repeat content" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/form_xobject.pdf", receiver)
@@ -182,7 +182,7 @@ def show_text_with_positioning(*params)
receiver.content[1].should eql("James Healy")
end
- specify "should correctly process a PDF that uses Form XObjects to repeat content" do
+ it "should correctly process a PDF that uses Form XObjects to repeat content" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/form_xobject_more.pdf", receiver)
@@ -198,7 +198,7 @@ def show_text_with_positioning(*params)
receiver.content[1].include?("James Healy").should be_true
end
- specify "should correctly process a PDF that uses indirect Form XObjects to repeat content" do
+ it "should correctly process a PDF that uses indirect Form XObjects to repeat content" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/indirect_xobject.pdf", receiver)
@@ -206,7 +206,7 @@ def show_text_with_positioning(*params)
receiver.content.size.should eql(1)
end
- specify "should correctly process a PDF that uses multiple content streams for a single page" do
+ it "should correctly process a PDF that uses multiple content streams for a single page" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/split_params_and_operator.pdf", receiver)
@@ -216,7 +216,7 @@ def show_text_with_positioning(*params)
receiver.content[0].include?("James Healy").should be_true
end
- specify "should correctly process a PDF that has a single space after the EOF marker" do
+ it "should correctly process a PDF that has a single space after the EOF marker" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/space_after_eof.pdf", receiver)
@@ -225,7 +225,7 @@ def show_text_with_positioning(*params)
receiver.content[0].should eql("HelloWorld")
end
- specify "should correctly extract text from a PDF that was generated in open office 3" do
+ it "should correctly extract text from a PDF that was generated in open office 3" do
receiver = PageTextReceiver.new
PDF::Reader.file(File.dirname(__FILE__) + "/data/oo3.pdf", receiver)
diff --git a/specs/metadata_spec.rb b/spec/metadata_spec.rb
similarity index 80%
rename from specs/metadata_spec.rb
rename to spec/metadata_spec.rb
index 89ad0707..23df2343 100644
--- a/specs/metadata_spec.rb
+++ b/spec/metadata_spec.rb
@@ -3,10 +3,10 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::MetadataVisitor do
+describe PDF::Reader::MetadataVisitor do
include EncodingHelper
- specify "should send the correct metadata callbacks when processing an PrinceXML PDF" do
+ it "should send the correct metadata callbacks when processing an PrinceXML PDF" do
receiver = PDF::Reader::RegisterReceiver.new
@@ -20,7 +20,7 @@
meta[:Producer].should eql("YesLogic Prince 5.1")
end
- specify "should send the correct metadata callbacks when processing an openoffice PDF" do
+ it "should send the correct metadata callbacks when processing an openoffice PDF" do
receiver = PDF::Reader::RegisterReceiver.new
@@ -36,7 +36,7 @@
meta[:CreationDate].should eql("D:20070623021705+10'00'")
end
- specify "should send the correct xml_metadata callbacks when processing a distiller PDF" do
+ it "should send the correct xml_metadata callbacks when processing a distiller PDF" do
receiver = PDF::Reader::RegisterReceiver.new
@@ -50,7 +50,7 @@
meta.include?("file://C:\\Data\\website\\i18nguy\\unicode-example.html").should be_true
end
- specify "should send the correct page count callback when processing an openoffice PDF" do
+ it "should send the correct page count callback when processing an openoffice PDF" do
receiver = PDF::Reader::RegisterReceiver.new
@@ -61,7 +61,7 @@
cb[:args].first.should eql(2)
end
- specify "should send the correct pdf_version callback when processing an openoffice PDF" do
+ it "should send the correct pdf_version callback when processing an openoffice PDF" do
receiver = PDF::Reader::RegisterReceiver.new
diff --git a/specs/object_hash_spec.rb b/spec/object_hash_spec.rb
similarity index 69%
rename from specs/object_hash_spec.rb
rename to spec/object_hash_spec.rb
index b1b68fd7..afa3f79f 100644
--- a/specs/object_hash_spec.rb
+++ b/spec/object_hash_spec.rb
@@ -3,8 +3,8 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::ObjectHash do
- specify "should have enumerable mixed in" do
+describe PDF::Reader::ObjectHash do
+ it "should have enumerable mixed in" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -12,8 +12,8 @@
end
end
-context PDF::Reader::ObjectHash do
- specify "should correctly load a PDF from a StringIO object" do
+describe PDF::Reader::ObjectHash do
+ it "should correctly load a PDF from a StringIO object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
io = StringIO.new(File.read(filename))
h = PDF::Reader::ObjectHash.new(io)
@@ -21,15 +21,15 @@
h.map { |ref, obj| obj.class }.size.should eql(57)
end
- specify "should raise an ArgumentError if passed a non filename and non IO" do
+ it "should raise an ArgumentError if passed a non filename and non IO" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
lambda {PDF::Reader::ObjectHash.new(10)}.should raise_error(ArgumentError)
end
end
-context PDF::Reader::ObjectHash, "[] method" do
+describe PDF::Reader::ObjectHash, "[] method" do
- specify "should return nil for any invalid hash key" do
+ it "should return nil for any invalid hash key" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -38,14 +38,14 @@
h["James"].should be_nil
end
- specify "should return nil for any hash key that doesn't exist" do
+ it "should return nil for any hash key that doesn't exist" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
h[10000].should be_nil
end
- specify "should correctly extract an int object using int or string keys" do
+ it "should correctly extract an int object using int or string keys" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -54,7 +54,7 @@
h["3james"].should eql(3649)
end
- specify "should correctly extract an int object using PDF::Reference as a key" do
+ it "should correctly extract an int object using PDF::Reference as a key" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
ref = PDF::Reader::Reference.new(3,0)
@@ -63,9 +63,9 @@
end
end
-context PDF::Reader::ObjectHash, "object method" do
+describe PDF::Reader::ObjectHash, "object method" do
- specify "should return regular objects unchanged" do
+ it "should return regular objects unchanged" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -74,7 +74,7 @@
h.object("James").should eql("James")
end
- specify "should translate reference objects into an extracted PDF object" do
+ it "should translate reference objects into an extracted PDF object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -82,9 +82,9 @@
end
end
-context PDF::Reader::ObjectHash, "fetch method" do
+describe PDF::Reader::ObjectHash, "fetch method" do
- specify "should raise IndexError for any invalid hash key when no default is provided" do
+ it "should raise IndexError for any invalid hash key when no default is provided" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -93,14 +93,14 @@
lambda { h.fetch("James") }.should raise_error(IndexError)
end
- specify "should return default for any hash key that doesn't exist when a default is provided" do
+ it "should return default for any hash key that doesn't exist when a default is provided" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
h.fetch(10000, "default").should eql("default")
end
- specify "should correctly extract an int object using int or string keys" do
+ it "should correctly extract an int object using int or string keys" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -109,7 +109,7 @@
h.fetch("3james").should eql(3649)
end
- specify "should correctly extract an int object using PDF::Reader::Reference keys" do
+ it "should correctly extract an int object using PDF::Reader::Reference keys" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
ref = PDF::Reader::Reference.new(3,0)
@@ -118,9 +118,9 @@
end
end
-context PDF::Reader::ObjectHash, "each method" do
+describe PDF::Reader::ObjectHash, "each method" do
- specify "should iterate 57 times when using cairo-unicode PDF" do
+ it "should iterate 57 times when using cairo-unicode PDF" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -131,7 +131,7 @@
count.should eql(57)
end
- specify "should provide a PDF::Reader::Reference to each iteration" do
+ it "should provide a PDF::Reader::Reference to each iteration" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -142,9 +142,9 @@
end
end
-context PDF::Reader::ObjectHash, "each_key method" do
+describe PDF::Reader::ObjectHash, "each_key method" do
- specify "should iterate 57 times when using cairo-unicode PDF" do
+ it "should iterate 57 times when using cairo-unicode PDF" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -155,7 +155,7 @@
count.should eql(57)
end
- specify "should provide a PDF::Reader::Reference to each iteration" do
+ it "should provide a PDF::Reader::Reference to each iteration" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -165,9 +165,9 @@
end
end
-context PDF::Reader::ObjectHash, "each_value method" do
+describe PDF::Reader::ObjectHash, "each_value method" do
- specify "should iterate 57 times when using cairo-unicode PDF" do
+ it "should iterate 57 times when using cairo-unicode PDF" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -179,9 +179,9 @@
end
end
-context PDF::Reader::ObjectHash, "size method" do
+describe PDF::Reader::ObjectHash, "size method" do
- specify "should return 57 when using cairo-unicode PDF" do
+ it "should return 57 when using cairo-unicode PDF" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -189,9 +189,9 @@
end
end
-context PDF::Reader::ObjectHash, "empty? method" do
+describe PDF::Reader::ObjectHash, "empty? method" do
- specify "should return false when using cairo-unicode PDF" do
+ it "should return false when using cairo-unicode PDF" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -199,9 +199,9 @@
end
end
-context PDF::Reader::ObjectHash, "has_key? method" do
+describe PDF::Reader::ObjectHash, "has_key? method" do
- specify "should return true when called with a valid ID" do
+ it "should return true when called with a valid ID" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -209,7 +209,7 @@
h.has_key?(PDF::Reader::Reference.new(1,0)).should be_true
end
- specify "should return false when called with an invalid ID" do
+ it "should return false when called with an invalid ID" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -220,16 +220,16 @@
end
end
-context PDF::Reader::ObjectHash, "has_value? method" do
+describe PDF::Reader::ObjectHash, "has_value? method" do
- specify "should return true when called with a valid object" do
+ it "should return true when called with a valid object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
h.has_value?(3649).should be_true
end
- specify "should return false when called with an invalid object" do
+ it "should return false when called with an invalid object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -239,9 +239,9 @@
end
end
-context PDF::Reader::ObjectHash, "keys method" do
+describe PDF::Reader::ObjectHash, "keys method" do
- specify "should return an array of keys" do
+ it "should return an array of keys" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -251,9 +251,9 @@
end
end
-context PDF::Reader::ObjectHash, "values method" do
+describe PDF::Reader::ObjectHash, "values method" do
- specify "should return an array of object" do
+ it "should return an array of object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -263,9 +263,9 @@
end
end
-context PDF::Reader::ObjectHash, "values_at method" do
+describe PDF::Reader::ObjectHash, "values_at method" do
- specify "should return an array of object" do
+ it "should return an array of object" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
ref3 = PDF::Reader::Reference.new(3,0)
@@ -276,9 +276,9 @@
end
end
-context PDF::Reader::ObjectHash, "to_a method" do
+describe PDF::Reader::ObjectHash, "to_a method" do
- specify "should return an array of 57 arrays" do
+ it "should return an array of 57 arrays" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -288,9 +288,9 @@
end
end
-context PDF::Reader::ObjectHash, "trailer method" do
+describe PDF::Reader::ObjectHash, "trailer method" do
- specify "should return the document trailer dictionary" do
+ it "should return the document trailer dictionary" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -303,9 +303,9 @@
end
end
-context PDF::Reader::ObjectHash, "pdf_version method" do
+describe PDF::Reader::ObjectHash, "pdf_version method" do
- specify "should return the document PDF version dictionary" do
+ it "should return the document PDF version dictionary" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
@@ -313,9 +313,9 @@
end
end
-context PDF::Reader::ObjectHash, "page_references method" do
+describe PDF::Reader::ObjectHash, "page_references method" do
- specify "should return the document PDF version dictionary" do
+ it "should return the document PDF version dictionary" do
filename = File.dirname(__FILE__) + "/data/cairo-unicode.pdf"
h = PDF::Reader::ObjectHash.new(filename)
diff --git a/specs/object_stream_spec.rb b/spec/object_stream_spec.rb
similarity index 79%
rename from specs/object_stream_spec.rb
rename to spec/object_stream_spec.rb
index ee532eac..98dcc176 100644
--- a/specs/object_stream_spec.rb
+++ b/spec/object_stream_spec.rb
@@ -3,14 +3,14 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::ObjectStream, "[] method" do
+describe PDF::Reader::ObjectStream, "[] method" do
before(:each) do
@hash = {:N=>2, :Type=>:ObjStm, :First=>11}
@data = "29 0 30 48 <><
>"
end
- specify "should provide access to 2 embedded objects" do
+ it "should provide access to 2 embedded objects" do
stream = PDF::Reader::Stream.new(@hash, @data)
obj_stream = PDF::Reader::ObjectStream.new(stream)
@@ -21,7 +21,7 @@
obj_stream[30][:S].should eql(:Document)
end
- specify "should return nil for objects it doesn't contain" do
+ it "should return nil for objects it doesn't contain" do
stream = PDF::Reader::Stream.new(@hash, @data)
obj_stream = PDF::Reader::ObjectStream.new(stream)
@@ -30,14 +30,14 @@
end
-context PDF::Reader::ObjectStream, "size method" do
+describe PDF::Reader::ObjectStream, "size method" do
before(:each) do
@hash = {:N=>2, :Type=>:ObjStm, :First=>11}
@data = "29 0 30 48 <><>"
end
- specify "should return the number of embedded objects" do
+ it "should return the number of embedded objects" do
stream = PDF::Reader::Stream.new(@hash, @data)
obj_stream = PDF::Reader::ObjectStream.new(stream)
diff --git a/specs/pages_visitor_spec.rb b/spec/pages_visitor_spec.rb
similarity index 88%
rename from specs/pages_visitor_spec.rb
rename to spec/pages_visitor_spec.rb
index fe4759e9..b33e0629 100644
--- a/specs/pages_visitor_spec.rb
+++ b/spec/pages_visitor_spec.rb
@@ -7,9 +7,9 @@ class PDF::Reader::PagesVisitor
public :content_stream
end
-context PDF::Reader::PagesVisitor do
+describe PDF::Reader::PagesVisitor do
- specify "should send the correct callbacks when processing instructions containing a single text block" do
+ it "should send the correct callbacks when processing instructions containing a single text block" do
# mock up an object that will be called with callbacks. This will test that
# the content class correctly recognises all instructions
@@ -29,7 +29,7 @@ class PDF::Reader::PagesVisitor
content.content_stream(instructions, {:F1 => PDF::Reader::Font.new})
end
- specify "should send the correct callbacks when processing instructions containing 2 text blocks" do
+ it "should send the correct callbacks when processing instructions containing 2 text blocks" do
# mock up an object that will be called with callbacks. This will test that
# the content class correctly recognises all instructions
@@ -49,7 +49,7 @@ class PDF::Reader::PagesVisitor
content.content_stream(instructions, {:F1 => PDF::Reader::Font.new})
end
- specify "should send the correct callbacks when processing instructions containing an inline image" do
+ it "should send the correct callbacks when processing instructions containing an inline image" do
# mock up an object that will be called with callbacks. This will test that
# the content class correctly recognises all instructions
@@ -75,7 +75,7 @@ class PDF::Reader::PagesVisitor
# test for a bug reported by Jack Rusher where params at the end of a stream would be
# silently dropped if their matching operator was in the next contream stream in a series
- specify "should send the correct callbacks when processing a PDF with content over multiple streams" do
+ it "should send the correct callbacks when processing a PDF with content over multiple streams" do
receiver = PDF::Reader::RegisterReceiver.new
diff --git a/specs/parser_spec.rb b/spec/parser_spec.rb
similarity index 88%
rename from specs/parser_spec.rb
rename to spec/parser_spec.rb
index 9df3445c..81b840e2 100644
--- a/specs/parser_spec.rb
+++ b/spec/parser_spec.rb
@@ -3,11 +3,11 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Parser do
+describe PDF::Reader::Parser do
include ParserHelper
include EncodingHelper
- specify "should parse a name correctly" do
+ it "should parse a name correctly" do
parse_string("/James").parse_token.should eql(:James)
parse_string("/A;Name_With-Various***Characters?").parse_token.should eql(:"A;Name_With-Various***Characters?")
parse_string("/1.2").parse_token.should eql(:"1.2")
@@ -20,21 +20,21 @@
# '/' is a valid PDF name, but :"" is not a valid ruby symbol.
# How should I handle this?
- specify "should parse an empty name correctly" #do
+ it "should parse an empty name correctly" #do
#parse_string("/").parse_token.should eql(:"")
#end
- specify "should parse booleans correctly" do
+ it "should parse booleans correctly" do
parse_string("true").parse_token.should be_true
parse_string("false").parse_token.should be_false
end
- specify "should parse null and nil correctly" do
+ it "should parse null and nil correctly" do
parse_string("").parse_token.should be_nil
parse_string("null").parse_token.should be_nil
end
- specify "should parse a string correctly" do
+ it "should parse a string correctly" do
parse_string("()").parse_token.should eql("")
parse_string("(this is a string)").parse_token.should eql("this is a string")
parse_string("(this \\n is a string)").parse_token.should eql("this \n is a string")
@@ -59,7 +59,7 @@
parse_string("([test])").parse_token.should eql("[test]")
end
- specify "should parse a Unicode string correctly" do
+ it "should parse a Unicode string correctly" do
seq = {
# key source expected confusing to
:straddle_seq_5c6e =>["\x4F\x5C\x5C\x6E\x05", "\x4F\x5C\x6E\x05"], # /.\n./
@@ -97,27 +97,27 @@
parse_string(mixed_src).parse_token.should eql(mixed_exp)
end
- specify "should not leave the closing literal string delimiter in the buffer after parsing a string" do
+ it "should not leave the closing literal string delimiter in the buffer after parsing a string" do
parser = parse_string("(this is a string) /James")
parser.parse_token.should eql("this is a string")
parser.parse_token.should eql(:James)
end
- specify "should parse a hex string correctly" do
+ it "should parse a hex string correctly" do
parse_string("<48656C6C6F>").parse_token.should eql("Hello")
end
- specify "should ignore whitespace when parsing a hex string" do
+ it "should ignore whitespace when parsing a hex string" do
parse_string("<48656C6C6F20\n4A616D6573>").parse_token.should eql("Hello James")
end
- specify "should parse dictionary with embedded hex string correctly" do
+ it "should parse dictionary with embedded hex string correctly" do
dict = parse_string("<< /X <48656C6C6F> >>").parse_token
dict.size.should eql(1)
dict[:X].should eql("Hello")
end
- specify "should parse various dictionaries correctly" do
+ it "should parse various dictionaries correctly" do
str = "<< /Registry (Adobe) /Ordering (Japan1) /Supplement 5 >>"
dict = parse_string(str).parse_token
@@ -127,7 +127,7 @@
dict[:Supplement].should eql(5)
end
- specify "should parse an array correctly" do
+ it "should parse an array correctly" do
parse_string("[ 10 0 R 12 0 R ]").parse_token.size.should eql(2)
end
diff --git a/specs/reader_spec.rb b/spec/reader_spec.rb
similarity index 72%
rename from specs/reader_spec.rb
rename to spec/reader_spec.rb
index e21125a0..e09e9442 100644
--- a/specs/reader_spec.rb
+++ b/spec/reader_spec.rb
@@ -3,44 +3,44 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader, "file class method" do
+describe PDF::Reader, "file class method" do
before(:each) do
@receiver = PDF::Reader::RegisterReceiver.new
@filename = File.dirname(__FILE__) + "/data/cairo-unicode-short.pdf"
end
- specify "should parse all aspects of a PDF file by default" do
+ it "should parse all aspects of a PDF file by default" do
PDF::Reader.file(@filename, @receiver)
@receiver.count(:begin_document).should eql(1)
@receiver.count(:metadata).should eql(1)
end
- specify "should not provide raw text callbacks by default" do
+ it "should not provide raw text callbacks by default" do
PDF::Reader.file(@filename, @receiver)
@receiver.count(:show_text_with_positioning).should eql(1)
@receiver.count(:show_text_with_positioning_raw).should eql(0)
end
- specify "should provide raw text callbacks if requested" do
+ it "should provide raw text callbacks if requested" do
PDF::Reader.file(@filename, @receiver, :raw_text => true)
@receiver.count(:show_text_with_positioning).should eql(1)
@receiver.count(:show_text_with_positioning_raw).should eql(1)
end
- specify "should not parse metadata if requested" do
+ it "should not parse metadata if requested" do
PDF::Reader.file(@filename, @receiver, :metadata => false)
@receiver.count(:begin_document).should eql(1)
@receiver.count(:metadata).should eql(0)
end
- specify "should not parse page content if requested" do
+ it "should not parse page content if requested" do
PDF::Reader.file(@filename, @receiver, :pages => false)
@receiver.count(:begin_document).should eql(0)
@receiver.count(:metadata).should eql(1)
end
- specify "should raise an exception if an encrypted file is opened" do
+ it "should raise an exception if an encrypted file is opened" do
filename = File.dirname(__FILE__) + "/data/difference_table_encrypted.pdf"
lambda {
PDF::Reader.file(filename, @receiver)
@@ -48,7 +48,7 @@
end
end
-context PDF::Reader, "string class method" do
+describe PDF::Reader, "string class method" do
before(:each) do
@receiver = PDF::Reader::RegisterReceiver.new
@@ -60,37 +60,37 @@
end
end
- specify "should parse all aspects of a PDF file by default" do
+ it "should parse all aspects of a PDF file by default" do
PDF::Reader.string(@data, @receiver)
@receiver.count(:begin_document).should eql(1)
@receiver.count(:metadata).should eql(1)
end
- specify "should not provide raw text callbacks by default" do
+ it "should not provide raw text callbacks by default" do
PDF::Reader.string(@data, @receiver)
@receiver.count(:show_text_with_positioning).should eql(1)
@receiver.count(:show_text_with_positioning_raw).should eql(0)
end
- specify "should provide raw text callbacks if requested" do
+ it "should provide raw text callbacks if requested" do
PDF::Reader.string(@data, @receiver, :raw_text => true)
@receiver.count(:show_text_with_positioning).should eql(1)
@receiver.count(:show_text_with_positioning_raw).should eql(1)
end
- specify "should parse not parse metadata if requested" do
+ it "should parse not parse metadata if requested" do
PDF::Reader.string(@data, @receiver, :metadata => false)
@receiver.count(:begin_document).should eql(1)
@receiver.count(:metadata).should eql(0)
end
- specify "should parse not parse page content if requested" do
+ it "should parse not parse page content if requested" do
PDF::Reader.string(@data, @receiver, :pages => false)
@receiver.count(:begin_document).should eql(0)
@receiver.count(:metadata).should eql(1)
end
- specify "should raise an exception if an encrypted file is opened" do
+ it "should raise an exception if an encrypted file is opened" do
filename = File.dirname(__FILE__) + "/data/difference_table_encrypted.pdf"
if File.respond_to?(:binread)
@data = File.binread(filename)
@@ -103,21 +103,21 @@
end
end
-context PDF::Reader, "object_file class method" do
+describe PDF::Reader, "object_file class method" do
before(:each) do
@filename = File.dirname(__FILE__) + "/data/cairo-unicode-short.pdf"
end
- specify "should extract an object from string containing a full PDF file" do
+ it "should extract an object from string containing a full PDF file" do
PDF::Reader.object_file(@filename, 7, 0).should eql(515)
end
- specify "should extract an object from string containing a full PDF file" do
+ it "should extract an object from string containing a full PDF file" do
PDF::Reader.object_file(@filename, 7).should eql(515)
end
end
-context PDF::Reader, "object_string class method" do
+describe PDF::Reader, "object_string class method" do
before(:each) do
filename = File.dirname(__FILE__) + "/data/cairo-unicode-short.pdf"
@@ -128,11 +128,11 @@
end
end
- specify "should extract an object from string containing a full PDF file" do
+ it "should extract an object from string containing a full PDF file" do
PDF::Reader.object_string(@data, 7, 0).should eql(515)
end
- specify "should extract an object from string containing a full PDF file" do
+ it "should extract an object from string containing a full PDF file" do
PDF::Reader.object_string(@data, 7).should eql(515)
end
diff --git a/specs/spec_helper.rb b/spec/spec_helper.rb
similarity index 97%
rename from specs/spec_helper.rb
rename to spec/spec_helper.rb
index adc91505..a5cc6eec 100644
--- a/specs/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,6 +1,8 @@
# coding: utf-8
-$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+require "rubygems"
+require "bundler"
+Bundler.setup
require 'pdf/reader'
require 'timeout'
diff --git a/specs/stream_spec.rb b/spec/stream_spec.rb
similarity index 91%
rename from specs/stream_spec.rb
rename to spec/stream_spec.rb
index 20bb4962..300c4ad7 100644
--- a/specs/stream_spec.rb
+++ b/spec/stream_spec.rb
@@ -3,10 +3,10 @@
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
require File.dirname(__FILE__) + "/spec_helper"
-context PDF::Reader::Stream do
+describe PDF::Reader::Stream do
include EncodingHelper
- specify "should be able to decode streams that use FlateDecode" do
+ it "should be able to decode streams that use FlateDecode" do
decoded_stream = "\n0.000 0.000 0.000 rg\n0.000 0.000 0.000 RG\nq\n1 w\nQ\nq\n1 w\nQ\nq\nq\n430.000 0 0 787.000 300.000 50.000 cm\n/I0 Do\nQ\nq\n1.000 0.000 0.000 rg\n1.000 0.000 0.000 RG\n72.000 0.000 81.156 792.000 re f\n1.000 1.000 1.000 rg\n1.000 1.000 1.000 RG\nBT 0.000 1.000 -1.000 0.000 137.303 70.000 Tm /F1 72.0 Tf 0 Tr (PDF::Writer for Ruby) Tj ET\n1 w\nQ\nBT 536.664 711.216 Td /F1 24.0 Tf 0 Tr (\n) Tj ET\nBT 170.016 684.432 Td /F1 24.0 Tf 0 Tr (Native Ruby PDF Document Creation\n) Tj ET\nBT 540.220 662.112 Td /F1 20.0 Tf 0 Tr (\n) Tj ET\nBT 357.440 639.792 Td /F1 20.0 Tf 0 Tr (The Ruby PDF Project\n) Tj ET\nBT 237.480 617.472 Td ET\nq\n0.000 0.000 1.000 rg\n0.000 0.000 1.000 RG\n1.116 w [ ] 0 d\nBT 237.480 617.472 Td 0.000 Tw /F1 20.0 Tf 0 Tr (http://rubyforge.org/projects/ruby-pdf) Tj ET\n237.480 615.798 m\n540.220 615.798 l S\n1 w\nQ\nBT 540.220 617.472 Td /F1 20.0 Tf 0 Tr (\n) Tj ET\nBT 436.340 595.152 Td 0.000 Tw /F1 20.0 Tf 0 Tr (version 1.1.2\n) Tj ET\nBT 541.998 575.064 Td 0.000 Tw /F1 18.0 Tf 0 Tr (\n) Tj ET\nBT 368.748 554.976 Td 0.000 Tw /F1 18.0 Tf 0 Tr (Copyright \251 2003\2262005\n) Tj ET\nBT 437.508 534.888 Td 0.000 Tw ET\nq\n0.000 0.000 1.000 rg\n0.000 0.000 1.000 RG\n1.0044 w [ ] 0 d\nBT 437.508 534.888 Td /F1 18.0 Tf 0 Tr (Austin Ziegler) Tj ET\n437.508 533.381 m\n541.998 533.381 l S\n1 w\nQ\nBT 541.998 534.888 Td /F1 18.0 Tf 0 Tr (\n) Tj ET\n1 w\nQ"
io = File.new(File.dirname(__FILE__) + "/data/pdfwriter-manual.pdf")
@@ -16,9 +16,9 @@
obj.unfiltered_data.should eql(binary_string(decoded_stream))
end
- specify "should be able to decode streams that use FlateDecode with something funny about them"
+ it "should be able to decode streams that use FlateDecode with something funny about them"
- specify "should raise a MalformedPDFError when there's a problem decoding a Flated Stream" do
+ it "should raise a MalformedPDFError when there's a problem decoding a Flated Stream" do
decoded_stream = <