pdfjs_viewer-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +77 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/pdfjs_viewer/application.js +16 -0
- data/app/assets/javascripts/pdfjs_viewer/pdfjs/compatibility.js +574 -0
- data/app/assets/javascripts/pdfjs_viewer/pdfjs/l10n.js +1004 -0
- data/app/assets/javascripts/pdfjs_viewer/pdfjs/pdf.combined.js +44784 -0
- data/app/assets/javascripts/pdfjs_viewer/viewer.js +6883 -0
- data/app/assets/stylesheets/pdfjs_viewer/application.css +17 -0
- data/app/assets/stylesheets/pdfjs_viewer/full.scss +7 -0
- data/app/assets/stylesheets/pdfjs_viewer/minimal.scss +31 -0
- data/app/assets/stylesheets/pdfjs_viewer/pdfjs/viewer.css +1990 -0
- data/app/controllers/pdfjs_viewer/application_controller.rb +4 -0
- data/app/controllers/pdfjs_viewer/viewer_controller.rb +11 -0
- data/app/views/pdfjs_viewer/viewer/_viewer.html.erb +406 -0
- data/app/views/pdfjs_viewer/viewer/full.html.erb +1 -0
- data/app/views/pdfjs_viewer/viewer/minimal.html.erb +1 -0
- data/config/routes.rb +4 -0
- data/lib/pdfjs_viewer-rails.rb +18 -0
- data/lib/pdfjs_viewer-rails/helpers.rb +9 -0
- data/lib/pdfjs_viewer-rails/version.rb +5 -0
- data/lib/tasks/pdfjs_viewer_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/sample_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/sample/helper.html.erb +1 -0
- data/test/dummy/app/views/sample/show.html.erb +10 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +37 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +2455 -0
- data/test/dummy/log/test.log +1720 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/sample.pdf +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/full.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/minimal.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/04eae8bca898a65982980c3e50ad7fbd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/12f627b3c5f4d1ba551ec15071b146ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/179e183f4ee9ccca7c8937e398f7e5ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1a6d33544c20ead8fcebe2042ac1525b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/20cfc4824e896a020f7386bd98c340ed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/21b502c161a167bfdda0fb06fefe42b7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/24f6c5595a9b6a95fa1a17757c55261c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/395495688f5310d0645ec57873b2759e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/41a66f55761db630a20526b0b91e0343 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4509000351818b96fa2e5239cc0e089b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/595a531e01ee23e6221c62d6d311aba1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/597414ce2d02f11df6b8f2533b18b142 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6384899a9cb6e830fa5869ffd9de6544 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/730fa2b9535ffcaec1cb98f2daa2a15a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e62f2ade8de8c8d58ca24ea150a4b62 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/81bfd70f6ddb31a47b5fd2283f02068d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/87ba41d384f696d9f33bcbb6d81cbf38 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/940983b263c09cef8a392334a42dc2b7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9439817fb117375f337c0ad9a46b1f76 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a4b60d7ffa74f207fff9106821cd1759 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a7f3405fc7c670abe82e4e41c64b5a33 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a850909a3c37a59780d49c690374cf65 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ab7f07b8312f30b275efc7203f10ccda +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b134e335e41a782ac45a6f0441e5d0ee +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f16770b5fd41beb962f620a6f29110f1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fb9ab06a0b93b2a7be41b5ee91378ea2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ffcc4b97c4cc77c7660fc560d5b9c86d +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/full.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/minimal.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/04eae8bca898a65982980c3e50ad7fbd +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/12f627b3c5f4d1ba551ec15071b146ed +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1a6d33544c20ead8fcebe2042ac1525b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/21b502c161a167bfdda0fb06fefe42b7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/24f6c5595a9b6a95fa1a17757c55261c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/395495688f5310d0645ec57873b2759e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4509000351818b96fa2e5239cc0e089b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/595a531e01ee23e6221c62d6d311aba1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/597414ce2d02f11df6b8f2533b18b142 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/730fa2b9535ffcaec1cb98f2daa2a15a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7e62f2ade8de8c8d58ca24ea150a4b62 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/81bfd70f6ddb31a47b5fd2283f02068d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/940983b263c09cef8a392334a42dc2b7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9439817fb117375f337c0ad9a46b1f76 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a4b60d7ffa74f207fff9106821cd1759 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a7f3405fc7c670abe82e4e41c64b5a33 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a850909a3c37a59780d49c690374cf65 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b134e335e41a782ac45a6f0441e5d0ee +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f16770b5fd41beb962f620a6f29110f1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ffcc4b97c4cc77c7660fc560d5b9c86d +0 -0
- data/test/integration/viewer_test.rb +64 -0
- data/test/sandbox/full_viewer.png +0 -0
- data/test/sandbox/helper.png +0 -0
- data/test/sandbox/minimal_viewer.png +0 -0
- data/test/test_helper.rb +34 -0
- metadata +327 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/422.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/dummy/tmp/cache/assets/test/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/full.scssc
ADDED
Binary file
|
data/test/dummy/tmp/cache/assets/test/sass/f1b3e59e51ba5ccf8dc190375cfc40e8c38f8d16/minimal.scssc
ADDED
Binary file
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ViewerTest < ActionDispatch::IntegrationTest
|
4
|
+
setup do
|
5
|
+
@time_to_render = 2
|
6
|
+
end
|
7
|
+
|
8
|
+
test "Full viewer" do
|
9
|
+
visit "/"
|
10
|
+
output = capture(:stdout) do
|
11
|
+
click_on "full viewer"
|
12
|
+
assert_equal 1, all("#pdfjs_viewer-full").size
|
13
|
+
sleep @time_to_render
|
14
|
+
end
|
15
|
+
|
16
|
+
assert_rendered_pdf output, screenshot: SANDBOX_PATH + "full_viewer.png"
|
17
|
+
end
|
18
|
+
|
19
|
+
test "Minimal viewer" do
|
20
|
+
visit "/"
|
21
|
+
output = capture(:stdout) do
|
22
|
+
click_on "minimal viewer"
|
23
|
+
assert_equal 1, all("#pdfjs_viewer-minimal").size
|
24
|
+
sleep @time_to_render
|
25
|
+
end
|
26
|
+
|
27
|
+
assert_rendered_pdf output, screenshot: SANDBOX_PATH + "minimal_viewer.png"
|
28
|
+
end
|
29
|
+
|
30
|
+
test "Using the helper" do
|
31
|
+
visit "/"
|
32
|
+
output = capture(:stdout) do
|
33
|
+
click_on "helper"
|
34
|
+
assert_equal 1, all("#pdfjs_viewer-minimal").size
|
35
|
+
sleep @time_to_render
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_rendered_pdf output, screenshot: SANDBOX_PATH + "helper.png"
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def assert_rendered_pdf(output, screenshot:)
|
43
|
+
puts output.scan(/Warning:.+$/)
|
44
|
+
assert_match /PDF 48164f9cb09af89995618717f0aafc/, output
|
45
|
+
page.save_screenshot screenshot, full: true
|
46
|
+
end
|
47
|
+
|
48
|
+
def capture(stream)
|
49
|
+
stream = stream.to_s
|
50
|
+
captured_stream = Tempfile.new(stream)
|
51
|
+
stream_io = eval("$#{stream}")
|
52
|
+
origin_stream = stream_io.dup
|
53
|
+
stream_io.reopen(captured_stream)
|
54
|
+
|
55
|
+
yield
|
56
|
+
|
57
|
+
stream_io.rewind
|
58
|
+
return captured_stream.read
|
59
|
+
ensure
|
60
|
+
captured_stream.close
|
61
|
+
captured_stream.unlink
|
62
|
+
stream_io.reopen(origin_stream)
|
63
|
+
end
|
64
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
+
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
+
# ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
7
|
+
require "rails/test_help"
|
8
|
+
|
9
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
10
|
+
# to be shown.
|
11
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
12
|
+
|
13
|
+
# Load fixtures from the engine
|
14
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
15
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'capybara/rails'
|
19
|
+
require 'capybara/poltergeist'
|
20
|
+
require "timeout"
|
21
|
+
|
22
|
+
SANDBOX_PATH = Pathname.new(File.expand_path("sandbox", __dir__))
|
23
|
+
SANDBOX_PATH.each_child { |screenshot| screenshot.delete }
|
24
|
+
|
25
|
+
class ActionDispatch::IntegrationTest
|
26
|
+
include Capybara::DSL
|
27
|
+
Capybara.default_driver = :poltergeist
|
28
|
+
|
29
|
+
def teardown
|
30
|
+
super
|
31
|
+
Capybara.reset_sessions! # Forget the (simulated) browser state
|
32
|
+
Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
|
33
|
+
end
|
34
|
+
end
|