Sha256: b6569930858c4507129b8b4fe5efecd493f5a26c400ce87bf5bb3d0c5547006a
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
require 'test_helper' class ViewerTest < ActionDispatch::IntegrationTest setup do @time_to_render = 2 end test "Full viewer" do visit "/" output = capture(:stdout) do click_on "full viewer" assert_equal 1, all("#pdfjs_viewer-full").size sleep @time_to_render end assert_rendered_pdf output, screenshot: SANDBOX_PATH + "full_viewer.png" end test "Minimal viewer" do visit "/" output = capture(:stdout) do click_on "minimal viewer" assert_equal 1, all("#pdfjs_viewer-minimal").size sleep @time_to_render end assert_rendered_pdf output, screenshot: SANDBOX_PATH + "minimal_viewer.png" end test "Using the helper" do visit "/" output = capture(:stdout) do click_on "helper" assert_equal 1, all("#pdfjs_viewer-minimal").size sleep @time_to_render end assert_rendered_pdf output, screenshot: SANDBOX_PATH + "helper.png" end private def assert_rendered_pdf(output, screenshot:) puts output.scan(/Warning:.+$/) assert_match(/PDF d6ea82b9661e58030e99729d198a353a/, output) page.save_screenshot screenshot, full: true end def capture(stream) stream = stream.to_s captured_stream = Tempfile.new(stream) stream_io = eval("$#{stream}") origin_stream = stream_io.dup stream_io.reopen(captured_stream) yield stream_io.rewind return captured_stream.read ensure captured_stream.close captured_stream.unlink stream_io.reopen(origin_stream) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pdfjs_viewer-rails-0.0.8 | test/integration/viewer_test.rb |