wicked_pdf_capybara 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5bbcbe5861fa44237df489f03344fe47bb8955a1
4
+ data.tar.gz: a76301e29179a82ae041e71e0d2b87e236e4c3c6
5
+ SHA512:
6
+ metadata.gz: a55f03686f2290a8be9e369bf7fe720178f4b3e771fa544d7108305faced1c9ba7e0561626c97a9a8fdc93fb9ff167ea224358f25ff0aa40946c4bd354a9c32a
7
+ data.tar.gz: fd916fb547a0eb15dace19961d16bed94ac43104c5474acad3e515b29b1de0706e9bd40ec29be8bc250b782f9bb9d9656cf04948391430ba542a705392aa3d07
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in wicked_pdf_capybara.gemspec
6
+ gemspec
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wicked_pdf_capybara (0.1.0)
5
+ pdf-reader (>= 2.1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ Ascii85 (1.0.3)
11
+ afm (0.2.2)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ hashery (2.1.2)
15
+ method_source (0.9.0)
16
+ pdf-reader (2.1.0)
17
+ Ascii85 (~> 1.0.0)
18
+ afm (~> 0.2.1)
19
+ hashery (~> 2.0)
20
+ ruby-rc4
21
+ ttfunk
22
+ pry (0.11.3)
23
+ coderay (~> 1.1.0)
24
+ method_source (~> 0.9.0)
25
+ rake (10.4.2)
26
+ rspec (3.7.0)
27
+ rspec-core (~> 3.7.0)
28
+ rspec-expectations (~> 3.7.0)
29
+ rspec-mocks (~> 3.7.0)
30
+ rspec-core (3.7.1)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-expectations (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-mocks (3.7.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.7.0)
38
+ rspec-support (3.7.1)
39
+ ruby-rc4 (0.1.5)
40
+ ttfunk (1.5.1)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.16)
47
+ pry
48
+ rake (~> 10.0)
49
+ rspec (~> 3.0)
50
+ wicked_pdf_capybara!
51
+
52
+ BUNDLED WITH
53
+ 1.16.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ryan Murphy
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.
@@ -0,0 +1,23 @@
1
+ # Wicked PDF Capybara
2
+
3
+ Wicked PDF Capybara is an extension on the Capybara testing library for PDFs. This gem parses the text content of a document generated with WickedPDF to allow testing of content.
4
+
5
+ ## Install
6
+
7
+ Add to the Gemfile of your project. Capybara must be included for this to work.
8
+
9
+ ```ruby
10
+ gem 'capybara'
11
+ gem 'wicked_pdf_capybara'
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ In an integration test, visit your pdf page and call `pdf_text` on your `page` to get the entire text from the document.
17
+ ```ruby
18
+ expect(page.pdf_text).to include('Success')
19
+ ```
20
+
21
+ ## License
22
+
23
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wicked_pdf_capybara"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,2 @@
1
+ require 'wicked_pdf_capybara/version'
2
+ require 'wicked_pdf_capybara/session'
@@ -0,0 +1,27 @@
1
+ require 'pdf-reader'
2
+ require 'tempfile'
3
+ module Capybara
4
+ class Session
5
+ def pdf_text
6
+ begin
7
+ parsed_pdf_text
8
+ rescue ArgumentError, PDF::Reader::MalformedPDFError
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def temp_pdf
15
+ temp_pdf = Tempfile.new('pdf')
16
+ temp_pdf << source.force_encoding('UTF-8')
17
+ end
18
+
19
+ def pdf_reader
20
+ PDF::Reader.new(temp_pdf)
21
+ end
22
+
23
+ def parsed_pdf_text
24
+ pdf_reader.pages.map(&:text).first.gsub("\n", ' ').gsub("\t", ' ')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module WickedPdfCapybara
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'wicked_pdf_capybara/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'wicked_pdf_capybara'
7
+ spec.version = WickedPdfCapybara::VERSION
8
+ spec.authors = ['Ryan Murphy']
9
+ spec.email = ['murjax@gmail.com']
10
+
11
+ spec.summary = %q{A Capybara extension to allow testing of Wicked PDF content.}
12
+ spec.description = %q{A Capybara extension to allow testing of Wicked PDF content.}
13
+ spec.homepage = 'https://github.com/murjax/wicked_pdf_capybara'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'pdf-reader', '>= 2.1.0'
22
+ spec.add_development_dependency 'pry'
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wicked_pdf_capybara
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Murphy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pdf-reader
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: A Capybara extension to allow testing of Wicked PDF content.
84
+ email:
85
+ - murjax@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/wicked_pdf_capybara.rb
101
+ - lib/wicked_pdf_capybara/session.rb
102
+ - lib/wicked_pdf_capybara/version.rb
103
+ - wicked_pdf_capybara.gemspec
104
+ homepage: https://github.com/murjax/wicked_pdf_capybara
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubyforge_project:
124
+ rubygems_version: 2.5.2
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A Capybara extension to allow testing of Wicked PDF content.
128
+ test_files: []