poltergeist-screenshot_overview 0.1.8 → 0.2.1
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 +4 -4
- data/lib/poltergeist/screenshot_overview/capybara_patch.rb +49 -0
- data/lib/poltergeist/screenshot_overview/manager.rb +25 -6
- data/lib/poltergeist/screenshot_overview/rspec.rb +6 -3
- data/lib/poltergeist/screenshot_overview/version.rb +1 -1
- data/lib/poltergeist/screenshot_overview.rb +0 -34
- data/templates/layout.erb +75 -64
- data/templates/screenshot.erb +22 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b91cf4b227b7cb2262672190cc89ab4c1ea3e8cc
|
4
|
+
data.tar.gz: b38d9f89fe29f258da38b2f991091c25918e03e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27f3e49938bc7d6f40cef9b5e213c58d3d142eaa86e0c4b1a7c82198363a88c9235070d393db5453c8eeb902fb8743df7d4f1a14030497e2420c56e9b079510b
|
7
|
+
data.tar.gz: d940561a9de23b6a0f2d52b344838c2517e51b216047d9255a2efa1b2edd6e5fba7f53480a7cf9d85222391180af5e3e8ec894f439829a6a71fc4b090868041d
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Poltergeist::ScreenshotOverview
|
2
|
+
module CapybaraPatch
|
3
|
+
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
|
7
|
+
# @override
|
8
|
+
def visit(url)
|
9
|
+
with_screenshot(url, page.visit(url))
|
10
|
+
end
|
11
|
+
|
12
|
+
# @override
|
13
|
+
def click_button(*args)
|
14
|
+
# page.send method, *args, &block
|
15
|
+
with_screenshot(args.first, page.click_button(*args))
|
16
|
+
end
|
17
|
+
|
18
|
+
# @override
|
19
|
+
def click_link(*args)
|
20
|
+
with_screenshot(args.first, page.click_link(*args))
|
21
|
+
end
|
22
|
+
|
23
|
+
# @override
|
24
|
+
def click_on(*args)
|
25
|
+
with_screenshot(args.first, page.click_on(*args))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def with_screenshot(url, result)
|
32
|
+
make_screenshot(url)
|
33
|
+
result
|
34
|
+
end
|
35
|
+
|
36
|
+
def make_screenshot(argument)
|
37
|
+
if defined?(RSpec.current_example)
|
38
|
+
ex = RSpec.current_example
|
39
|
+
else
|
40
|
+
ex = example
|
41
|
+
end
|
42
|
+
if ex && (ex.metadata[:js] || ex.metadata[:screenshot])
|
43
|
+
filename = Manager.instance.add_image_from_rspec(argument, ex, current_path)
|
44
|
+
page.driver.render(Rails.root.join(filename).to_s, full: true)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "erb"
|
2
2
|
require "ostruct"
|
3
3
|
module Poltergeist::ScreenshotOverview
|
4
|
-
class
|
4
|
+
class ExampleFile
|
5
5
|
attr_accessor :screenshots, :file_name
|
6
6
|
|
7
7
|
def initialize(file,screenshots)
|
@@ -12,6 +12,24 @@ module Poltergeist::ScreenshotOverview
|
|
12
12
|
def to_id
|
13
13
|
file_name.gsub(/\W+/, "-").gsub(/^-/, "")
|
14
14
|
end
|
15
|
+
|
16
|
+
def examples
|
17
|
+
screenshots.group_by{|i| i.example_description }.map do |_,screenshots|
|
18
|
+
Example.new(screenshots)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Example
|
24
|
+
attr_accessor :screenshots
|
25
|
+
def initialize(screenshots)
|
26
|
+
@screenshots = screenshots.sort_by{|i| i.file_with_line }
|
27
|
+
end
|
28
|
+
|
29
|
+
def title
|
30
|
+
(screenshots.first.group_description + [screenshots.first.example_description]).join(' >> ')
|
31
|
+
end
|
32
|
+
|
15
33
|
end
|
16
34
|
|
17
35
|
class Screenshot
|
@@ -38,11 +56,11 @@ module Poltergeist::ScreenshotOverview
|
|
38
56
|
end
|
39
57
|
|
40
58
|
def snippet
|
41
|
-
File.read(full_test_path).lines[ line_number -
|
59
|
+
File.read(full_test_path).lines[ line_number - 5, 9].tap{|i| i[4] = ">>" + i[4].gsub(/^ /,'')}.join
|
42
60
|
end
|
43
61
|
|
44
62
|
def test_file
|
45
|
-
|
63
|
+
file_with_line.gsub(Dir.pwd, '').gsub(/:\d+$/,'')
|
46
64
|
end
|
47
65
|
|
48
66
|
def render
|
@@ -92,10 +110,11 @@ module Poltergeist::ScreenshotOverview
|
|
92
110
|
end
|
93
111
|
|
94
112
|
|
95
|
-
def
|
96
|
-
@
|
113
|
+
def example_files
|
114
|
+
@example_files ||=
|
115
|
+
@files.
|
97
116
|
group_by{ |screenshot| screenshot.test_file}.
|
98
|
-
map{|file,screenshots|
|
117
|
+
map{|file,screenshots| ExampleFile.new(file,screenshots.sort_by{|s| s.file_with_line }) }
|
99
118
|
end
|
100
119
|
|
101
120
|
end
|
@@ -1,5 +1,11 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
# require 'poltergeist'
|
1
3
|
require "poltergeist/screenshot_overview"
|
2
4
|
require "poltergeist/screenshot_overview/manager"
|
5
|
+
require "poltergeist/screenshot_overview/capybara_patch"
|
6
|
+
|
7
|
+
Capybara::DSL.send(:include, Poltergeist::ScreenshotOverview::CapybaraPatch)
|
8
|
+
|
3
9
|
RSpec.configure do |config|
|
4
10
|
config.before(:suite) do
|
5
11
|
Poltergeist::ScreenshotOverview::Manager.instance.start
|
@@ -7,7 +13,4 @@ RSpec.configure do |config|
|
|
7
13
|
config.after(:suite) do
|
8
14
|
Poltergeist::ScreenshotOverview::Manager.instance.generate_html
|
9
15
|
end
|
10
|
-
|
11
|
-
config.include Poltergeist::ScreenshotOverview, :type => :feature, :js => true
|
12
|
-
|
13
16
|
end
|
@@ -20,39 +20,5 @@ module Poltergeist
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
# @override
|
24
|
-
def visit(*args)
|
25
|
-
super
|
26
|
-
make_screenshot(args.first)
|
27
|
-
end
|
28
|
-
|
29
|
-
# @override
|
30
|
-
def click_button(*args)
|
31
|
-
super
|
32
|
-
make_screenshot(args.first)
|
33
|
-
end
|
34
|
-
|
35
|
-
# @override
|
36
|
-
def click_link(*args)
|
37
|
-
super
|
38
|
-
make_screenshot(args.first)
|
39
|
-
end
|
40
|
-
|
41
|
-
def click_on(*args)
|
42
|
-
super
|
43
|
-
make_screenshot(args.first)
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def make_screenshot(argument)
|
49
|
-
return if !defined?(RSpec.current_example)
|
50
|
-
ex = RSpec.current_example
|
51
|
-
if ex && (ex.metadata[:js] || ex.metadata[:screenshot])
|
52
|
-
filename = Manager.instance.add_image_from_rspec(argument, ex, current_path)
|
53
|
-
page.driver.render(Rails.root.join(filename).to_s,full: true)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
23
|
end
|
58
24
|
end
|
data/templates/layout.erb
CHANGED
@@ -1,79 +1,90 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html class="no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
3
3
|
<title><%= title %></title>
|
4
|
-
<meta name="description" content="">
|
5
|
-
<meta name="viewport" content="width=device-width">
|
6
|
-
<link href="//
|
4
|
+
<meta name="description" content="">
|
5
|
+
<meta name="viewport" content="width=device-width">
|
6
|
+
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
|
7
7
|
|
8
|
-
<style type='text/css'>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
8
|
+
<style type='text/css'>
|
9
|
+
.screenshot {
|
10
|
+
margin-bottom: 15px;
|
11
|
+
padding-bottom: 15px;
|
12
|
+
border-bottom: 2px solid #aaa;
|
13
|
+
vertical-align: top;
|
14
|
+
display: inline-block;
|
15
|
+
}
|
16
|
+
#container {
|
17
|
+
width: 80%;
|
18
|
+
margin: 0 auto;
|
19
|
+
padding: 0 20px;
|
20
|
+
font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
|
21
|
+
}
|
22
|
+
#toc {
|
23
|
+
width: 200px;
|
24
|
+
background-color: #FFFFFF;
|
25
|
+
border-radius: 6px 6px 6px 6px;
|
26
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
|
27
|
+
margin: 30px 0 0;
|
28
|
+
padding: 0;
|
29
|
+
}
|
30
|
+
#toc a {
|
31
|
+
border: 1px solid #E5E5E5;
|
32
|
+
display: block;
|
33
|
+
margin: 0 0 -1px;
|
34
|
+
padding: 8px 14px;
|
35
|
+
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
36
|
+
}
|
37
|
+
</style>
|
36
38
|
|
37
|
-
<script type='text/javascript'>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
</script>
|
39
|
+
<script type='text/javascript'>
|
40
|
+
//url = window.location.toString();
|
41
|
+
//console.log(url)
|
42
|
+
//if (!/\/$/.test(url)) {
|
43
|
+
// url = url + '/';
|
44
|
+
// window.location = url
|
45
|
+
//}
|
46
|
+
</script>
|
45
47
|
|
46
48
|
</head>
|
47
49
|
|
48
50
|
<body data-spy="scroll" data-target=".navbar">
|
51
|
+
<div class='container-fluid'>
|
49
52
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
<div id='container' class='row'>
|
54
|
+
<div class='col-sm-8 col-lg-10'>
|
55
|
+
<h1><%= title %></h1>
|
56
|
+
<% example_files.each do |file| %>
|
57
|
+
<div class='group'>
|
58
|
+
<h2 id='<%=file.to_id%>'><%= file.file_name %></h2>
|
59
|
+
<% file.examples.each do |example| %>
|
60
|
+
<h4><%= example.title %></h4>
|
61
|
+
<% example.screenshots.each do |screenshot| %>
|
62
|
+
<%= screenshot.render %>
|
63
|
+
<% end %>
|
64
|
+
<% end %>
|
65
|
+
</div>
|
66
|
+
<% end %>
|
67
|
+
</div>
|
62
68
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
<div class='col-sm-4 col-lg-2'>
|
70
|
+
<div class='navbar' id='toc' data-spy="affix" data-offset-top="200">
|
71
|
+
<ul class='nav nav-list'>
|
72
|
+
<% example_files.each do |group| %>
|
73
|
+
<li>
|
74
|
+
<a href='#<%=group.to_id %>'><%= group.file_name %></a>
|
75
|
+
</li>
|
76
|
+
<% end %>
|
77
|
+
</div>
|
78
|
+
</div>
|
71
79
|
</div>
|
72
80
|
</div>
|
73
|
-
</div>
|
74
81
|
|
75
|
-
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
|
76
|
-
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
|
77
|
-
<script src=
|
78
|
-
|
82
|
+
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
|
83
|
+
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
|
84
|
+
<script type='application/javascript' src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
|
85
|
+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/styles/default.min.css">
|
86
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.7/highlight.min.js"></script>
|
87
|
+
<script>hljs.initHighlightingOnLoad();</script>
|
88
|
+
|
89
|
+
</body>
|
79
90
|
</html>
|
data/templates/screenshot.erb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
<div class='screenshot'>
|
2
|
-
|
3
|
-
<
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
<% id = 'modal' + Digest::MD5.hexdigest(file_with_line) %>
|
3
|
+
<a href='#<%=id%>' data-toggle='modal'>
|
4
|
+
<img src='<%= local_image %>' alt='' style='width: 100px'/>
|
5
|
+
</a>
|
6
|
+
|
7
|
+
<div class="modal fade" id='<%=id%>'>
|
8
|
+
<div class="modal-dialog modal-lg">
|
9
|
+
<div class="modal-content">
|
10
|
+
<div class="modal-header">
|
11
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
12
|
+
<h3 class='modal-title'><%= group_description.join(" >> ") %> <%= example_description %></h3>
|
13
|
+
</div>
|
14
|
+
<div class="modal-body">
|
15
|
+
<p>URL: <code><%= url %></code></p>
|
16
|
+
<p>clicked on: <code><%= argument %></code></p>
|
17
|
+
<p><a href='file://<%= file_with_line %>'><%= file_with_line %></a></p>
|
18
|
+
<pre><code lang='ruby' class='ruby'><%= snippet %></code></pre>
|
19
|
+
<img src='<%= local_image %>' alt='' class='img-responsive'/>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</div>
|
12
24
|
</div>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poltergeist-screenshot_overview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Wienert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: poltergeist
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
68
|
- lib/poltergeist/screenshot_overview.rb
|
69
|
+
- lib/poltergeist/screenshot_overview/capybara_patch.rb
|
69
70
|
- lib/poltergeist/screenshot_overview/manager.rb
|
70
71
|
- lib/poltergeist/screenshot_overview/rspec.rb
|
71
72
|
- lib/poltergeist/screenshot_overview/version.rb
|