poltergeist-screenshot_overview 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1744d28bde763b93b11818cca9b4421b4c71b241
4
+ data.tar.gz: 35cedb245667cd83dcac2d4b0bc38015f5317930
5
+ SHA512:
6
+ metadata.gz: 2b69854cc37a6691dbf63e28a6071985e2be9a83a5c67111a5cd9b7929c6f09e723679f30401562aa2397f590e523b219cc5a602cc44dd72101203b295ab333b
7
+ data.tar.gz: 059a2ca4bb34395b6f8119a1c8c28c75413110c2e9753bdcf039bfd3e3f04732100dd7c425ac84d9aedee0e3cfeb35583f8d3222c78bfa773d5cd177ec46fcd8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in poltergeist-screenshot_overview.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Stefan Wienert
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Poltergeist::ScreenshotOverview
2
+
3
+ Hooks into Capybara poltergeist to automatically make screenshots after each click. Until now, only rspec supported. (Different test environments should be easy to plug in).
4
+
5
+
6
+ ## Motivation
7
+
8
+ Sometimes we ran into problems:
9
+ * Some recent design changes broke something on a completly different site.
10
+ *
11
+
12
+ We run this on the Continuos Integration server, so we get an up2date overview of most application's views rendered on a full blown Chromium (thx to poltergeist and Phantomjs).
13
+
14
+ ## Usage
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ group :test do
19
+ gem 'poltergeist-screenshot_overview'
20
+ end
21
+
22
+
23
+ As the gem's name suggest, poltergeist and so Capybara is required.
24
+
25
+ ### Rspec
26
+
27
+ puts this in your spec_helper.rb somewhere below application loading:
28
+
29
+ require "poltergeist/screenshot_overview/rspec"
30
+
31
+ Run your feature specs. Every visit, click_button and click_link will create a screenshot into public/cockpit.
32
+
33
+ After test run, visit localhost:3000/cockpit/index.html in your browser to view the screenshots.
34
+
35
+ NOTE: only feature specs with ``js: true`` will be run, to avoid problems with
36
+
37
+ ## Configuration
38
+
39
+ Change setting with:
40
+
41
+ Poltergeist::ScreenshotOverview.target_directory = 'public/cockpit'
42
+ Poltergeist::ScreenshotOverview.layout = 'GEM_DIR/templates/layout.erb'
43
+ Poltergeist::ScreenshotOverview.template = 'GEM_DIR/templates/screenshot.erb'
44
+
45
+ NOTE: before test execution, all jpg's in target_directory are deleted.
46
+
47
+ To render different Styles
48
+
49
+ ## Contributing
50
+
51
+ Possibly needed features
52
+ * Other than rspec's adapters (mini-test)
53
+ * Could run with different Browsers that support screenshoting, but so far only Poltergeist implemented
54
+ * UI
55
+ * general styling
56
+ * some kind of TOC, affix or stuff
57
+ * line numbers, file open links
58
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,49 @@
1
+ require "poltergeist/screenshot_overview/manager"
2
+ module Poltergeist
3
+ module ScreenshotOverview
4
+ class << self
5
+ attr_writer :target_directory
6
+ attr_writer :layout
7
+ attr_writer :template
8
+
9
+ def target_directory
10
+ @target_directory || "public/cockpit"
11
+ end
12
+
13
+ def layout
14
+ @layout || File.join(File.dirname(__FILE__), "../../templates/layout.erb")
15
+ end
16
+ def template
17
+ @layout || File.join(File.dirname(__FILE__), "../../templates/screenshot.erb")
18
+ end
19
+ end
20
+
21
+ # @override
22
+ def visit(*args)
23
+ super
24
+ make_screenshot(args.first)
25
+ end
26
+
27
+ # @override
28
+ def click_button(*args)
29
+ super
30
+ make_screenshot(args.first)
31
+ end
32
+
33
+ # @override
34
+ def click_link(*args)
35
+ super
36
+ make_screenshot(args.first)
37
+ end
38
+
39
+ private
40
+
41
+ def make_screenshot(argument)
42
+ if self.example.metadata[:js] || self.example.metadata[:screenshot]
43
+ filename = Manager.instance.add_image_from_rspec(argument, self.example, current_path)
44
+ page.driver.render(Rails.root.join(filename).to_s,full: true)
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,52 @@
1
+ require "erb"
2
+ require "ostruct"
3
+ module Poltergeist::ScreenshotOverview
4
+ class Manager
5
+ include Singleton
6
+
7
+ def start
8
+ Dir[File.join Poltergeist::ScreenshotOverview.target_directory, "*jpg"].each do |file|
9
+ File.unlink file
10
+ end
11
+ @files = []
12
+ end
13
+
14
+ # adds image_path and metadata to our list, returns a full path where the
15
+ # Engine should put the screenshot in
16
+ def add_image_from_rspec(argument, example, url_path)
17
+ filename = [example.description, argument, Digest::MD5.hexdigest("foo")[0..6] ].join(" ").gsub(/\W+/,"_") + ".jpg"
18
+
19
+ full_name = File.join(Poltergeist::ScreenshotOverview.target_directory, filename )
20
+ FileUtils.mkdir_p Poltergeist::ScreenshotOverview.target_directory
21
+ describe = example.metadata[:example_group][:description_args]
22
+ @files << {
23
+ :url => url_path,
24
+ :argument => argument,
25
+ :local_image => filename,
26
+ :full_path => full_name,
27
+ :test_file => example.file_path,
28
+ :describe_descriptions => describe,
29
+ :example_description => example.description
30
+ }
31
+ full_name
32
+ end
33
+
34
+ def generate_html
35
+ title = "Screenshot Overview (#{Time.now.to_s})"
36
+ template = ERB.new File.new(Poltergeist::ScreenshotOverview.layout).read, nil, "%"
37
+ html = template.result(binding)
38
+ File.open( File.join(Poltergeist::ScreenshotOverview.target_directory, "index.html"), "w+") { |f|
39
+ f.write html }
40
+ end
41
+
42
+
43
+ def rendered_screenshots
44
+ template = ERB.new File.read(Poltergeist::ScreenshotOverview.template), nil, "%"
45
+ @files.map do |file|
46
+ namespace = OpenStruct.new(file)
47
+ template.result(namespace.instance_eval { binding })
48
+ end.join
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ require "poltergeist/screenshot_overview"
2
+ require "poltergeist/screenshot_overview/manager"
3
+ RSpec.configure do |config|
4
+ config.before(:suite) do
5
+ Poltergeist::ScreenshotOverview::Manager.instance.start
6
+ end
7
+ config.after(:suite) do
8
+ Poltergeist::ScreenshotOverview::Manager.instance.generate_html
9
+ end
10
+
11
+ config.include Poltergeist::ScreenshotOverview, :type => :feature, :js => true
12
+
13
+ end
@@ -0,0 +1,5 @@
1
+ module Poltergeist
2
+ module ScreenshotOverview
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'poltergeist/screenshot_overview/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "poltergeist-screenshot_overview"
8
+ spec.version = "0.0.1"
9
+ spec.authors = ["Stefan Wienert"]
10
+ spec.email = ["stefan.wienert@pludoni.de"]
11
+ spec.description = %q{hooks into Capybara poltergeist to automatically make screenshots after each click}
12
+ spec.summary = %q{Useful for running in Continuos integration server, so the designer can look up, after recent design changes, if anything broke. One get's a brief overview over the application wide style renderings (on Chrome).}
13
+ spec.homepage = "https://github.com/zealot128/poltergeist-screenshot_overview"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "poltergeist"
22
+ spec.add_runtime_dependency "erb"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html>
2
+ <html class="no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
3
+ <title><%= title %></title>
4
+ <meta name="description" content="">
5
+ <meta name="viewport" content="width=device-width">
6
+
7
+ <style type='text/css'>
8
+ .screenshot {
9
+ margin-bottom: 15px;
10
+ padding-bottom: 15px;
11
+ border-bottom: 2px solid #aaa;
12
+ }
13
+ #container {
14
+ width: 80%;
15
+ margin: 0 auto;
16
+ padding: 0 20px;
17
+ font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
18
+ }
19
+ </style
20
+
21
+ </head>
22
+
23
+ <body>
24
+
25
+ <div id='container'>
26
+ <h1><%= title %></h1>
27
+
28
+ <%= rendered_screenshots %>
29
+ </div>
30
+
31
+ </body>
32
+ </html>
@@ -0,0 +1,13 @@
1
+ <div class='screenshot'>
2
+ <img src='<%= local_image %>' alt=''/>
3
+
4
+ <ul>
5
+ <li>
6
+ <strong><%= describe_descriptions.join(" >> ") %>:
7
+ <%= example_description %></strong>
8
+ </li>
9
+ <li>on <%= url %></li>
10
+ <li>in <%= test_file %></li>
11
+ <li>clicked on /visited: "<%= argument %>"</li>
12
+ </table>
13
+ </div>
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: poltergeist-screenshot_overview
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Wienert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: poltergeist
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: erb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: hooks into Capybara poltergeist to automatically make screenshots after
70
+ each click
71
+ email:
72
+ - stefan.wienert@pludoni.de
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/poltergeist/screenshot_overview.rb
83
+ - lib/poltergeist/screenshot_overview/manager.rb
84
+ - lib/poltergeist/screenshot_overview/rspec.rb
85
+ - lib/poltergeist/screenshot_overview/version.rb
86
+ - poltergeist-screenshot_overview.gemspec
87
+ - templates/layout.erb
88
+ - templates/screenshot.erb
89
+ homepage: https://github.com/zealot128/poltergeist-screenshot_overview
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.0.rc.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Useful for running in Continuos integration server, so the designer can look
113
+ up, after recent design changes, if anything broke. One get's a brief overview over
114
+ the application wide style renderings (on Chrome).
115
+ test_files: []
116
+ has_rdoc: