poltergeist-screenshot_overview 0.0.3 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/poltergeist/screenshot_overview/manager.rb +67 -16
- data/poltergeist-screenshot_overview.gemspec +1 -1
- data/templates/layout.erb +54 -6
- data/templates/screenshot.erb +5 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b43612594d07f1ad1194b19a341e32abb3a65c7f
|
4
|
+
data.tar.gz: aa91e1375f94cfc87b3e8cb8d53d86dda4ffb094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e0b877c56e0e58a49b72784ae8018d845274513f3d07943835ebf9843d1d3be799031216f7138f2a94ddc4989a18021e917e2a58a765f592646a8a5b44f38a
|
7
|
+
data.tar.gz: 2823da18c09e8b37caac98f198025d65bc731423993068eb608f845824c326a0ee900201668fb6da5c4f782e2bca2cb5af33a85b6ec28c0e628d7453e6e6d3c8
|
@@ -1,6 +1,56 @@
|
|
1
1
|
require "erb"
|
2
2
|
require "ostruct"
|
3
3
|
module Poltergeist::ScreenshotOverview
|
4
|
+
class ScreenshotGroup
|
5
|
+
attr_accessor :screenshots, :file_name
|
6
|
+
|
7
|
+
def initialize(file,screenshots)
|
8
|
+
@file_name = file
|
9
|
+
@screenshots = screenshots
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_id
|
13
|
+
file_name.gsub(/\W+/, "-").gsub(/^-/, "")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Screenshot
|
18
|
+
ATTR = :url, :argument, :local_image, :full_path, :group_description, :example_description, :file_with_line
|
19
|
+
attr_accessor(*ATTR)
|
20
|
+
def initialize(opts={})
|
21
|
+
opts.each do |k,v|
|
22
|
+
self.send("#{k}=", v)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_hash
|
27
|
+
Hash[
|
28
|
+
ATTR.map{|k|[k, self.send(k)]}
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def line_number
|
33
|
+
file_with_line.split(":")[1].to_i rescue 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def full_test_path
|
37
|
+
file_with_line.split(":")[0]
|
38
|
+
end
|
39
|
+
|
40
|
+
def snippet
|
41
|
+
File.read(full_test_path).lines[ line_number - 3, 5].join
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_file
|
45
|
+
full_test_path.gsub(Dir.pwd, "").gsub("spec/features/","")
|
46
|
+
end
|
47
|
+
|
48
|
+
def render
|
49
|
+
template = ERB.new File.read(Poltergeist::ScreenshotOverview.template), nil, "%"
|
50
|
+
template.result(binding)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
4
54
|
class Manager
|
5
55
|
include Singleton
|
6
56
|
|
@@ -16,23 +66,26 @@ module Poltergeist::ScreenshotOverview
|
|
16
66
|
def add_image_from_rspec(argument, example, url_path)
|
17
67
|
filename = [example.description, argument, Digest::MD5.hexdigest("foo")[0..6] ].join(" ").gsub(/\W+/,"_") + ".jpg"
|
18
68
|
|
69
|
+
blob = caller.find{|i| i[ example.file_path.gsub(/:\d*|^\./,"") ]}
|
70
|
+
file_with_line = blob.split(":")[0,2].join(":")
|
71
|
+
|
19
72
|
full_name = File.join(Poltergeist::ScreenshotOverview.target_directory, filename )
|
20
73
|
FileUtils.mkdir_p Poltergeist::ScreenshotOverview.target_directory
|
21
74
|
describe = example.metadata[:example_group][:description_args]
|
22
|
-
@files << {
|
23
|
-
:url
|
24
|
-
:argument
|
25
|
-
:local_image
|
26
|
-
:full_path
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
}
|
75
|
+
@files << Screenshot.new({
|
76
|
+
:url => url_path,
|
77
|
+
:argument => argument,
|
78
|
+
:local_image => filename,
|
79
|
+
:full_path => full_name,
|
80
|
+
:group_description => describe,
|
81
|
+
:example_description => example.description,
|
82
|
+
:file_with_line => file_with_line
|
83
|
+
})
|
31
84
|
full_name
|
32
85
|
end
|
33
86
|
|
34
87
|
def generate_html
|
35
|
-
title = "Screenshot Overview (#{Time.now.to_s})"
|
88
|
+
title = title = "Screenshot Overview (#{Time.now.to_s})"
|
36
89
|
template = ERB.new File.new(Poltergeist::ScreenshotOverview.layout).read, nil, "%"
|
37
90
|
html = template.result(binding)
|
38
91
|
File.open( File.join(Poltergeist::ScreenshotOverview.target_directory, "index.html"), "w+") { |f|
|
@@ -40,12 +93,10 @@ module Poltergeist::ScreenshotOverview
|
|
40
93
|
end
|
41
94
|
|
42
95
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
template.result(namespace.instance_eval { binding })
|
48
|
-
end.join
|
96
|
+
def groups
|
97
|
+
@files.
|
98
|
+
group_by{ |screenshot| screenshot.test_file}.
|
99
|
+
map{|file,screenshots| ScreenshotGroup.new(file,screenshots) }
|
49
100
|
end
|
50
101
|
|
51
102
|
end
|
@@ -5,7 +5,7 @@ require 'poltergeist/screenshot_overview/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "poltergeist-screenshot_overview"
|
8
|
-
spec.version = "0.
|
8
|
+
spec.version = "0.1.3"
|
9
9
|
spec.authors = ["Stefan Wienert"]
|
10
10
|
spec.email = ["stefan.wienert@pludoni.de"]
|
11
11
|
spec.description = %q{hooks into Capybara poltergeist to automatically make screenshots after each click}
|
data/templates/layout.erb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
<title><%= title %></title>
|
4
4
|
<meta name="description" content="">
|
5
5
|
<meta name="viewport" content="width=device-width">
|
6
|
+
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
|
6
7
|
|
7
8
|
<style type='text/css'>
|
8
9
|
.screenshot {
|
@@ -16,17 +17,64 @@
|
|
16
17
|
padding: 0 20px;
|
17
18
|
font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
|
18
19
|
}
|
19
|
-
|
20
|
+
#toc {
|
21
|
+
width: 200px;
|
22
|
+
background-color: #FFFFFF;
|
23
|
+
border-radius: 6px 6px 6px 6px;
|
24
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
|
25
|
+
margin: 30px 0 0;
|
26
|
+
padding: 0;
|
27
|
+
}
|
28
|
+
#toc a {
|
29
|
+
border: 1px solid #E5E5E5;
|
30
|
+
display: block;
|
31
|
+
margin: 0 0 -1px;
|
32
|
+
padding: 8px 14px;
|
33
|
+
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
34
|
+
}
|
35
|
+
</style>
|
36
|
+
|
37
|
+
<script type='text/javascript'>
|
38
|
+
url = window.location.toString();
|
39
|
+
console.log(url)
|
40
|
+
if (!/\/$/.test(url)) {
|
41
|
+
url = url + '/';
|
42
|
+
console.log("CHANGING" + url)
|
43
|
+
window.location = url
|
44
|
+
}
|
45
|
+
</script>
|
20
46
|
|
21
47
|
</head>
|
22
48
|
|
23
|
-
<body>
|
49
|
+
<body data-spy="scroll" data-target=".navbar">
|
24
50
|
|
25
|
-
<div id='container'>
|
26
|
-
|
51
|
+
<div id='container' class='row'>
|
52
|
+
<div class='span10'>
|
53
|
+
<h1><%= title %></h1>
|
54
|
+
<% groups.each do |group| %>
|
55
|
+
<div class='group'>
|
56
|
+
<h2 id='<%=group.to_id%>'><%= group.file_name %></h2>
|
57
|
+
<% group.screenshots.each do |screenshot| %>
|
58
|
+
<%= screenshot.render %>
|
59
|
+
<% end %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
</div>
|
27
63
|
|
28
|
-
|
29
|
-
|
64
|
+
<div class='span2'>
|
65
|
+
<div class='navbar' id='toc' data-spy="affix" data-offset-top="200">
|
66
|
+
<ul class='nav nav-list'>
|
67
|
+
<% groups.each do |group| %>
|
68
|
+
<li>
|
69
|
+
<a href='#<%=group.to_id %>'><%= group.file_name %></a>
|
70
|
+
</li>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
</div>
|
30
75
|
|
76
|
+
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
|
77
|
+
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
|
78
|
+
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
31
79
|
</body>
|
32
80
|
</html>
|
data/templates/screenshot.erb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
<div class='screenshot'>
|
2
2
|
<img src='<%= local_image %>' alt=''/>
|
3
|
-
|
4
3
|
<ul>
|
5
4
|
<li>
|
6
|
-
|
7
|
-
<%= example_description %></strong>
|
5
|
+
<strong><%= group_description.join(" >> ") %> <%= example_description %></strong>
|
8
6
|
</li>
|
9
|
-
<li>
|
10
|
-
<li>
|
11
|
-
<li
|
7
|
+
<li>URL: <code><%= url %></code></li>
|
8
|
+
<li>clicked on: <code><%= argument %></code></li>
|
9
|
+
<li><a href='file://<%= file_with_line %>'><%= file_with_line %></a></li>
|
10
|
+
<code><pre><%= snippet %></pre></code>
|
12
11
|
</table>
|
13
12
|
</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.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Wienert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: poltergeist
|