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.

#!/usr/bin/env ruby

require_relative '../../spec_helper'

require 'rspec'

require 'thingfish'
require 'thingfish/processor'

require 'strelka'
require 'strelka/httprequest/metadata'


describe Thingfish::Processor, "PDF" do

	before( :all ) do
		Strelka::HTTPRequest.class_eval { include Strelka::HTTPRequest::Metadata }
	end


	let( :processor ) { described_class.create(:pdf) }

	let( :factory ) do
		Mongrel2::RequestFactory.new(
			:route => '/',
			:headers => {:accept => '*/*'})
	end


	it "extracts metadata from uploaded PDFs" do
		req = factory.post( '/tf', fixture_data('hi.pdf'), 'Content-type' => 'application/pdf' )

		processor.process_request( req )

		expect( req.metadata ).to include( 'pdf:pagecount', 'pdf:producer' )
	end
end

# vim: set nosta noet ts=4 sw=4 ft=rspec: