test-unit-pdf_matcher 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 81e35e02fd41985e231e0e937e5588310c991af07ceb5605d2c0da9a56610a40
4
+ data.tar.gz: 68db090d3becde960d1f283871944e57cd3b6c83c5ad315b2b3c69269a341859
5
+ SHA512:
6
+ metadata.gz: d66e57f8691eac3e88b97fcea5830d57ea5f1bbc8ad95c2f40009065cfa223c0255f3a5c7400114bbd1faf1ff225b464b2c4f0a545d04463212b045522236030
7
+ data.tar.gz: e511af2e44af1d856f7c9ee6a22cda7cae9b11faad8079cc3fe9cc9014e2494a07c7afdc3942c8716853d8af7f3dc8695ae8161a435a091b90bd62e8f47c62d1
@@ -0,0 +1,35 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ name: Test on ruby ${{ matrix.ruby_version }}
8
+ runs-on: ubuntu-latest
9
+
10
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
11
+
12
+ strategy:
13
+ matrix:
14
+ ruby_version:
15
+ - 2.6
16
+ - 2.7
17
+ - 3.0
18
+
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+
22
+ - uses: hidakatsuya/setup-diff-pdf@v1
23
+ with:
24
+ diff-pdf-version: 0.5
25
+
26
+ - name: Set up Ruby ${{ matrix.ruby_version }}
27
+ uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby_version }}
30
+
31
+ - name: Install dependencies
32
+ run: bundle install --jobs 4 --retry 3
33
+
34
+ - name: Run Tests
35
+ run: bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ /.bundle/
2
+ /pkg/
3
+ /tmp/
4
+ /Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## Main (Unreleased)
2
+
3
+ ## 1.0.0
4
+
5
+ The first release. See [README.md](README.md) for detailed instructions.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+ gem 'prawn'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Katsuya Hidaka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Test::Unit::PdfMatcher
2
+
3
+ [![Test](https://github.com/hidakatsuya/test-unit-pdf_matcher/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/hidakatsuya/test-unit-pdf_matcher/actions/workflows/test.yml)
4
+
5
+ This gem provides `assert_match_pdf` assertion by [PdfMatcher](https://github.com/hidakatsuya/pdf_matcher) to Test::Unit.
6
+
7
+ ## Prerequisites
8
+
9
+ This gem requires `diff-pdf`. See [the documentation of PdfMatcher](https://github.com/hidakatsuya/pdf_matcher#prerequisites) for details.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'test-unit-pdf_matcher'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle install
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install test-unit-pdf_matcher
26
+
27
+ ## Usage
28
+
29
+ Add this line to your `test_helper.rb`:
30
+
31
+ ```ruby
32
+ require 'test/unit/pdf_matcher`
33
+ ```
34
+
35
+ ### assert_match_pdf
36
+
37
+ ```ruby
38
+ assert_match_pdf pdf1_data, pdf2_data
39
+ assert_match_pdf '/path/to/1.pdf', '/path/to/2.pdf'
40
+ assert_match_pdf Pathnae('/path/to/1.pdf'), Pathname('/path/to/2.pdf')
41
+ ```
42
+
43
+ You can generate a difference PDF by `output_diff_path` option:
44
+
45
+ ```ruby
46
+ assert_match_pdf pdf1_data, pdf2_data, output_diff_path: '/path/to/diff.pdf'
47
+ ```
48
+
49
+ ### Configuring diff-pdf command options
50
+
51
+ ```ruby
52
+ ::PdfMatcher.config.diff_pdf_opts = %w(--dpi=300 --grayscale)
53
+ ```
54
+
55
+ See `diff-pdf --help` for the available diff-pdf options.
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test/unit'
4
+
5
+ require_relative 'pdf_matcher/version'
6
+ require_relative 'pdf_matcher/assertions'
7
+
8
+ module Test
9
+ module Unit
10
+ TestCase.include PdfMatcher::Assertions
11
+ end
12
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pdf_matcher'
4
+
5
+ module Test
6
+ module Unit
7
+ module PdfMatcher
8
+ module Assertions
9
+ # Passes if PdfMatcher.match?(`expected_pdf`, `actual_pdf`).
10
+ # See https://github.com/hidakatsuya/pdf_matcher for details about PdfMatcher.
11
+ #
12
+ # @example
13
+ # assert_match_pdf pdf1_data, pdf2_data, output_diff_path: '/path/to/diff.pdf'
14
+ # assert_match_pdf '/path/to/1.pdf', '/path/to/2.pdf'
15
+ # assert_match_pdf Pathname('/path/to/1.pdf'), Pathname('/path/to/2.pdf')
16
+ #
17
+ def assert_match_pdf(expected_pdf, actual_pdf, output_diff_path: nil)
18
+ full_messages = ['The PDF contents did not match.'].tap { |msgs|
19
+ msgs << "Check #{output_diff_path} for details of the differences." if output_diff_path
20
+ }
21
+ assert_block(full_messages.join(' ')) do
22
+ ::PdfMatcher.match?(expected_pdf, actual_pdf, output_diff: output_diff_path)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Test
4
+ module Unit
5
+ module PdfMatcher
6
+ VERSION = '1.0.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'lib/test/unit/pdf_matcher/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'test-unit-pdf_matcher'
5
+ spec.version = Test::Unit::PdfMatcher::VERSION
6
+ spec.authors = ['Katsuya Hidaka']
7
+ spec.email = ['hidakatsuya@gmail.com']
8
+
9
+ spec.summary = 'PdfMatcher for Test::Unit'
10
+ spec.description = 'This gem provides assert_match_pdf assertion by PdfMatcher to Test::Unit.'
11
+ spec.homepage = 'https://github.com/hidakatsuya/pdf_matcher-test_adapters/test-unit-pdf_matcher'
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = spec.homepage
17
+
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
20
+ end
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'pdf_matcher', '>= 1.0.0'
24
+ spec.add_dependency 'test-unit', '>= 3.4.0'
25
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-unit-pdf_matcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Katsuya Hidaka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pdf_matcher
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.4.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.4.0
41
+ description: This gem provides assert_match_pdf assertion by PdfMatcher to Test::Unit.
42
+ email:
43
+ - hidakatsuya@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".github/workflows/test.yml"
49
+ - ".gitignore"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/test/unit/pdf_matcher.rb
56
+ - lib/test/unit/pdf_matcher/assertions.rb
57
+ - lib/test/unit/pdf_matcher/version.rb
58
+ - test-unit-pdf_matcher.gemspec
59
+ homepage: https://github.com/hidakatsuya/pdf_matcher-test_adapters/test-unit-pdf_matcher
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/hidakatsuya/pdf_matcher-test_adapters/test-unit-pdf_matcher
64
+ source_code_uri: https://github.com/hidakatsuya/pdf_matcher-test_adapters/test-unit-pdf_matcher
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.6.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.1.6
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: PdfMatcher for Test::Unit
84
+ test_files: []