spec/thingfish/processor/pdf_spec.rb
author Mahlon E. Smith <mahlon@martini.nu>
Mon, 02 Sep 2019 09:22:50 -0700
changeset 4 cd8abe741d22
parent 0 266fe36d11dd
permissions -rw-r--r--
Bye, Bitbucket.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     1
#!/usr/bin/env ruby
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     2
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     3
require_relative '../../spec_helper'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     4
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     5
require 'rspec'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     6
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     7
require 'thingfish'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     8
require 'thingfish/processor'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
     9
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    10
require 'strelka'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    11
require 'strelka/httprequest/metadata'
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    12
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    13
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    14
describe Thingfish::Processor, "PDF" do
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    15
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    16
	before( :all ) do
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    17
		Strelka::HTTPRequest.class_eval { include Strelka::HTTPRequest::Metadata }
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    18
	end
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    19
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    20
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    21
	let( :processor ) { described_class.create(:pdf) }
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    22
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    23
	let( :factory ) do
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    24
		Mongrel2::RequestFactory.new(
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    25
			:route => '/',
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    26
			:headers => {:accept => '*/*'})
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    27
	end
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    28
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    29
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    30
	it "extracts metadata from uploaded PDFs" do
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    31
		req = factory.post( '/tf', fixture_data('hi.pdf'), 'Content-type' => 'application/pdf' )
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    32
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    33
		processor.process_request( req )
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    34
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    35
		expect( req.metadata ).to include( 'pdf:pagecount', 'pdf:producer' )
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    36
	end
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    37
end
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    38
266fe36d11dd Initial release.
Mahlon E. Smith <mahlon@laika.com>
parents:
diff changeset
    39
# vim: set nosta noet ts=4 sw=4 ft=rspec: