-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de5ab86
commit 2ca5ed6
Showing
10 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
language: ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
require 'rake/testtask' | ||
|
||
task default: 'test' | ||
|
||
Rake::TestTask.new do |t| | ||
t.test_files = FileList['test/**/*_test.rb'] | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'bundler/setup' | ||
require 'minitest/autorun' | ||
require 'minitest/around/spec' | ||
require 'combine_pdf' | ||
|
||
describe 'CombinePDF.load' do | ||
let(:options) { {} } | ||
|
||
subject { CombinePDF.load "test/fixtures/files/#{file}", options } | ||
|
||
describe 'raise_on_encrypted option' do | ||
let(:raise_on_encrypted) { false } | ||
let(:file) { 'sample_encrypted_pdf.pdf' } | ||
let(:options) { { raise_on_encrypted: raise_on_encrypted } } | ||
|
||
it('has a PDF') { assert_instance_of CombinePDF::PDF, subject } | ||
|
||
describe 'raise_on_encrypted: true' do | ||
let(:raise_on_encrypted) { true } | ||
|
||
it('raises an CombinePDF::EncryptionError') do | ||
assert_raises(CombinePDF::EncryptionError) { subject } | ||
end | ||
|
||
describe 'non-encrypted files' do | ||
let(:file) { 'sample_pdf.pdf' } | ||
|
||
it('has a PDF') { assert_instance_of CombinePDF::PDF, subject } | ||
end | ||
|
||
describe 'Zlib::DataError' do | ||
let(:encrypted?) { false } | ||
let(:parser) { Minitest::Mock.new } | ||
|
||
around do |example| | ||
parser.expect(:parse, true) { raise Zlib::DataError, 'incorrect data header' } | ||
root_object = encrypted? ? { Encrypt: :yes } : { NotEncrypted: :cool } | ||
parser.expect(:root_object, root_object) | ||
parser.expect(:raise_on_encrypted, raise_on_encrypted) | ||
parser.expect(:is_a?, true, [CombinePDF::PDFParser]) | ||
CombinePDF::PDFParser.stub(:new, parser) { |_| example.call } | ||
end | ||
|
||
it('raises Zlib::DataError') do | ||
assert_raises(Zlib::DataError) { subject } | ||
end | ||
|
||
describe 'encrypted' do | ||
let(:encrypted?) { true } | ||
|
||
it('raises an CombinePDF::EncryptionError') do | ||
assert_raises(CombinePDF::EncryptionError) { subject } | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.