ruby on rails - check prawn pdf content after rendering with rspec -


i'm trying test content of pdf generated prawn, sure information entered comes order. 1 in response, firstly i'm not sure content totally clean , secondly how read content? i'm trying pdf-inspector i'm not sure i'm doing right way.

in spec file :

get :invoice, params: {id: order.number, order_token: order.guest_token, format: :pdf}, format: :pdf pdf_doc = response.body rendered_pdf = pdf_doc.render text_analysis = pdf::inspector::text.analyze(rendered_pdf) puts text_analysis.strings 

rspec result :

  1) spree::orderscontroller#with right token should not return empty pdf      failure/error: rendered_pdf = pdf_doc.render       nomethoderror:        undefined method `render' #<string:0x0056490fd3b7c0>      # ./spec/controllers/spree/frontend/orders_controller_decorator_spec.rb:43:in `block (3 levels) in <top (required)>'  finished in 17.42 seconds (files took 8.08 seconds load) 1 example, 1 failure 

and response.body :

"%pdf-1.3\n%\xff\xff\xff\xff\n1 0 obj\n<< /creator <feff0050007200610077006e>\n/producer <feff0050007200610077006e>\n>>\nendobj\n2 0 obj\n<< /type /catalog\n/pages 3 0 r\n>>\nendobj\n3 0 obj\n<< /type /pages\n/count 1\n/kids [5 0 r]\n>>\nendobj\n4 0 obj\n<< /length 14202\n>>\nstream\nq\n/devicergb cs\n0.000 0.000 0.000 scn\n\nbt\n519.396 813.274 td\n/f2.0 12 tf\n[<46> 80 <41> 40 <4354555245>] tj\net\n\n\nq\n134.500 0 0 53.000 76.000 747.000 cm\n/i1 do\nq\n\nbt\n108.218 726.384 td\n/f1.0 12 tf\n[<4772> 10 <616e647376696e73>] tj\net\n\n\nbt\n79.598 712.512 td\n/f1.0 12 tf\n[<496d6d657562> 20 <6c652053e96d6170686f7265>] tj\net\n\n\nbt\n67.706 698.6399999999999 td\n/f1.0 12 tf\n[<31382072> -15 <756520426f696c656175202d204353203730303132>] tj\net\n\n\nbt\n64.442 684.7679999999998x00nq\xd2t~\xefz\xd0\xff\x00\x18\xfa\x7fk\xe6\xfd'\xb5\xcb\xfa\xc9\x9f\x85\xfa\xd3\x8bn\xaf\xa8c:\xbc\x1a\x1a\xd7\x90\xde\xa3s\xfe\xcf\xf6/}\x18\xd9\x1f\xad\xba\xcf\xe6\xb2\x7fkm\x98\x99*t\xf5\xbe\xab\x8d\x9ezi\xdb\xd43m\xb5\xe3\v.\xb1\xb4u\xbd\x98l\xce\xbe\xf6\xb7\x1f\x16\xcb\x18\xdb\x9f\xbf\xf4_\xa6\xff\x00\x83\xf4\xebc\xc3\xff\x00\xc4\xf7\xd5\x7f\xf8\xfco\xfc\xf7r\xba?\xf1d\x7f\xf0\xd9\xff\x00\xdb&!\xf6\xa3\xf54~]\xa5\xf6\xff\x00\x92\xf9}_\xdfe\x83\xf5\xbf\xedyx-~;1\xb1s\xab\xa8\xb2\xe7\xd8\xe7\x13u\xccu\xa3\x1a\xbff\x87\xd4\xd7\xd6\xea\xf6~\xb7v'\xda?\x9d\xc7]\"\xf3\xfe\x99\xff\x00\x8bn\x85\xff\x00\xa6\xa6\xff\x00\xd4\xde\xbd\x01\x10\xc3\x9b\xda\xb1\xedmz\xff\x00{\xfc'\xff\xd9\x008bim\x04!\x00\x00\x00\x00\x00]\x00\x00\x00\x01\x01\x00\x00\x00\x0f\x00a\x00d\x00o\x00b\x00e\x00 \x00p\x00h\x00o\x00t\x00o\x00s\x00h\x00o\x00p\x00\x00\x00\x17\x00a\x00d\x00o\x00b\x00e\x00 \x00p\x00h\x00o\x00t\x00o\x00s\x00h\x00o\x00p\x00 \x00c\x00c\x00 \x002\x000\x001\x007\x00\x00\x00\x01\x008bim\x04\x06\x00\x00\x00\x00\x00\a........................................................................................................................................................................................................................................1c\x00\x0f\x00\x1a\x00+acspappl\x00\x00\x00\x00appl\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\xf6\xd6\x00\x01\x00\x00\x00\x00\xd3-appl\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11desc\x00\x00\x01p\x00\x00\x00bdscm\x00\x00\x01\xb4\x00\x00\x01\xc0cprt\x00\x00\x03t\x00\x00\x00#wtpt\x00\x00\x03\x98\x00\x00\x00\x14rxyz\x00\x00\x03\xac\x00\x00\x00\x14gxyz\x00\x00\x03\xc0\x00\x00\x00\x14bxyz\x00\x00\x03\xd4\x00\x00\x00\x14rtrc\x00\x00\x03\xe8\x00\x00\b\faarg\x00\x00\v\xf4\x00\x00\x00 vcgt\x00\x00\f\x14\x00\x00\x000ndin\x00\x00\fd\x00\x00\x00>chad\x00\x00\f\x84\x00\x00\x00,mmod\x00\x00\f\xb0\x00\x00\x00(btrc\x00\x00\x03\xe8\x00\x00\b\fgtrc\x00\x00\x03\xe8\x00\x00\b\faabg\x00\x00\v\xf4\x00\x00\x00 aagg\x00\x00\v\xf4\x00\x00\x00 desc\x00\x00\x00\x00\x00\x00\x00\bdisplay\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00mluc\x00\x00\x00\x00\x00\x00\x00\"\x00\x00\x00\fhrhr\x00\x00\x00\x18\x00\x00\x01\xa8kokr\x00\x00\x00\x18\x00\x00\x01\xa8nbno\x00\x00\x00\x18\x00\x00\x01\xa8id\x00\x00\x00\x00\x00\x18\x00\x00\x01\xa8huhu\x00\x00\x00\x18\x00\x00\x01\xa8cscz\x00\x00\x00\x18\x00\x00\x01\xa8dadk\x00\x00\x00\x18\x00\x00\x01\xa8ukua\x00\x00\x00\x18\x00\x00\x01\xa8ar\x00\x00\x00\x00\x00\x18\x00\x00\x01\xa8itit\x00\x00\x00\x18\x00\x00\x01\xa8roro\x00\x00\x00\x18\x00\x00\x01\xa8nlnl\x00\x00\x00\x18\x00\x00\x01\xa8heil\x00\x00\x00\x18\x00\x00\x01\xa8eses\x00\x00\x00\x18\x00\x00\x01\xa8fifi\x00\x00\x00\x18\x00\x00\x01\xa8zhtw\x00\x00\x00\x18\x00\x00\x01\xa8vivn\x00\x00\x00\x18\x00\x00\x01\xa8sksk\x00\x00\x00\x18\x00\x00\x01\xa8zhcn\x00\x00\x00\x18\x00\x00\x01\xa8ruru\x00\x00\x00\x18\x00\x00\x01\xa8frfr\x00\x00\x00\x18\x00\x00\x01\xa8ms\x00\x00\x00\x00\x00\x18\x00\x00\x01\xa8caes\x00\x00\x00\x18\x00\x00\x01\xa8thth\x00\x00\x00\x18\x00\x00\x01\xa8esxl\x00\x00\x00\x18\x00\x00\x01\xa8dede\x00\x00\x00\x18\x00\x00\x01\xa8enus\x00\x00\x00\x18\x00\x00\x01\xa8ptbr\x00\x00\x00\x18\x00\x00\x01\xa8plpl\x00\x00\x00\x18\x00\x00\x01\xa8elgr\x00\x00\x00\x18\x00\x00\x01\xa8svse\x00\x00\x00\x18\x00\x00\x01\xa8trtr\x00\x00\x00\x18\x00\x00\x01\xa8jajp\x00\x00\x00\x18\x00\x00\x01\xa8ptpt\x00\x00\x00\x18\x00\x00\x01\xa8\x00l\x00g\x00 \x00u\x00l\x00t\x00r\x00a\x00f\x00i\x00n\x00etext\x00\x00\x\x9d\xdd\xff\x00'u\xf1\xf5iw\xa3v(\x89ty?\x9b\x97\xff\x00&\xf96_\x96|\x9b\xf0'\xf4\xdf\x88\xfe\xb3\xf2u\xaa\x85\x9a\x9f\xbdm\xf7\x8d\x9d\xab\xfd]9\xb4\xa8\x89\xb1\xbe}@\xfe\\|\x9b'\xd1\x8f\x97\xbb\e\xf8\x1f\x88\xfe\xb3\xc5\xcby\x1dv^u\xd3\xe3?n~\xaa\xf1\xde\xecr\xe9\xcc\xa6\xbdb\\\x92\xd3;\xdb\xe6\xed\xab\xd1\xdf\x94\x87\xd2g\x93\xbe\t\xcf\xa3\xfc\x7f\xb1\xf9<\xd5so[\\#\xbd=\xed\xdf\xda\xda\xbc_\xa3\xae\v\xaf\xb0\xfa\x16\xb8\xfa2\xfa\x1c\xff\x00%\xf9\x95\xf0\x87\xf0\xff\x00\x15\xfdw\xe5ku7\xe5w\xcf\xfa\xe1\xdf^/\xef\xae\x17i\xfc:\x17\xcd\xb1~\xe3'\xf4u\xee\xe2z2\xf7>\xe5\xcf(x\xff\x00\xaa\xf1su\x1d\xca\xaf\xc6og}\x97\xbd\xe4\xd9\xeb\xe4[#q\xfc\xc7\xc9<\xdc\xfa\x19y\xdf\xe4>\xd4\xfa\x7f\xc5{>=*\x8d\xbdk\xe8;\xf6m\xdf\xeam\xfc:v\xbd\xd8\xdf\xa2\xe4\xbe\x8b\xfe\x91\x1f\xd1\x9f\xc0\xfc\x19}?\xf2\xfd\xe7\xe4\xebuw*\xf7c\x17\xb3\xbe\xb8\xf7\xbf\xd3\xa3:\x8d\x1dk\xfc$\x0f\xe5\xe3\xe8\xe3\xe9[\xcb\x9e\x1f\xa1|]\\\xdb\x8d\xfdk\xa0\xdd=\x93\xf5_\xf6v>-+x\xf4a\xe7\xa8\x7f,\x9d\x87\xe6'\x9d~\xe0\xbe\x8d\xf1~\xfb\xc5ow\x84\x17\xbbz~\x9f\xff\x00w\xf1\xf7\\\xbau\xafv5\x1c%\x11(\x89dj\"\xff\xd9\nendstream\nendobj\n8 0 obj\n<< /type /font\n/subtype /type1\n/basefont /helvetica\n/encoding /winansiencoding\n>>\nendobj\nxref\n0 9\n0000000000 65535 f \n0000000015 00000 n \n0000000109 00000 n \n0000000158 00000 n \n0000000215 00000 n \n0000014470 00000 n \n0000014687 00000 n \n0000014789 00000 n \n0000040507 00000 n \ntrailer\n<< /size 9\n/root 2 0 r\n/info 1 0 r\n>>\nstartxref\n40604\n%%eof\n" 

i deliberately shortened respons (.....) in terminal separated in 2 in example above.

i have content separated in 2 empty lines between them, looks pdf file


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -