-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from RoleModel/test-pdf-concern
Test Pdf Concern
- Loading branch information
Showing
3 changed files
with
42 additions
and
10 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
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,13 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
require 'test/jobs/test_generate_pdf_job' | ||
|
||
class Chromium::TestPdf < Minitest::Test | ||
# def test_that_it_has_a_version_number | ||
# refute_nil ::Chromium::Pdf::VERSION | ||
# end | ||
def test_job_includes_pdf_concern | ||
assert_respond_to TestGeneratePdfJob.new, :generate_pdf! | ||
end | ||
|
||
# def test_it_does_something_useful | ||
# assert false | ||
# end | ||
def test_generate_pdf_calls_chrome_print | ||
job = TestGeneratePdfJob.new | ||
job.stub :chrome_print, :ran do | ||
assert_equal :ran, job.generate_pdf!('filename', 'url') | ||
end | ||
end | ||
|
||
def test_chrome_print_calls_file_open | ||
job = TestGeneratePdfJob.new | ||
File.stub :open, :ran do | ||
result = job.send(:chrome_print, 'chrome', 'url', 'name', 'path', ['argument']) do |_file, filename| | ||
assert_equal 'name', filename | ||
end | ||
assert_equal :ran, result | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class TestGeneratePdfJob | ||
include Chromium::Pdf | ||
|
||
def perform(filename, url) | ||
generate_pdf!(filename, url) | ||
end | ||
end |