htmlcuke 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4066391cbb175c42721f8a2aa0340e443d24d8db
4
+ data.tar.gz: db5b76956b4b674a4d7343acc280cd4f81a34f79
5
+ SHA512:
6
+ metadata.gz: 146a02e7e82b665eb823b80258258574c5165b473715a99cae649e409c638e4652ef54426a100d38e319372f98bccb121ede3dcd7bbb38165029249b8672dfbf
7
+ data.tar.gz: 7458866ef3896dc0a7741c00a4c75a0e94e733caf7ee78a51048c85065e07589fccf13638e0a23465804afe5274a6ddcb0a9e7a0cdaf72293d1f3b6dd595d4d5
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in htmlcuke.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Nathan Ray
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,56 @@
1
+ # Htmlcuke
2
+
3
+ A custom Html formatter for Cucumber that provides specific functionality.
4
+ This formatter removes (if necessary) any color codes wrapped around puts statements within a suite that is using the ```colorized``` or similar gem.
5
+ The formatter also embeds a screenshot link of the last window focused in a failed test and opens the shot in a new tab upon clicking the link.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'htmlcuke'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install htmlcuke
20
+
21
+ ## Usage
22
+
23
+ This usage case assumes you have the directories ```reports``` and ```reports/screens``` located in the same directory within which your test will run.
24
+
25
+ Add this line to your cucumber.yml, Rakefile, or command line arguments:
26
+ ```
27
+ --format Htmlcuke::Formatter --out reports/cucumber_$(date '+%Y.%m.%d-%H.%M.%S').html
28
+ ```
29
+
30
+ The --out assumes you will output the .html files to the reports directory under the naming convention cucumber + timestamp, feel free to change this as you see fit.
31
+
32
+ A sample after hook in hooks.rb would be:
33
+
34
+ ```ruby
35
+ After do |scenario|
36
+ Dir::mkdir('reports') unless File.directory?('reports')
37
+ Dir::mkdir('reports/screens') unless File.directory?('reports/screens')
38
+ if scenario.failed?
39
+ if scenario.respond_to?('scenario_outline')
40
+ screenshot = "./results/FAILED_#{(scenario.scenario_outline.title + ' ' + scenario.name).gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
41
+ screenshot_format = "./reports/screens/FAILED_#{(scenario.scenario_outline.title + ' ' + scenario.name).gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
42
+ else
43
+ screenshot = "./results/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
44
+ screenshot_format = "./reports/screens/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
45
+ end
46
+ end
47
+ end
48
+ ```
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it ( https://github.com/[my-github-username]/htmlcuke/fork )
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/htmlcuke.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'htmlcuke/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "htmlcuke"
8
+ spec.version = Htmlcuke::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ["Nathan Ray"]
11
+ spec.email = ["ntray1@gmail.com"]
12
+ spec.summary = %q{See https://github.com/maizaAvaro/Htmlcuke for a description and usage case}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/maizaAvaro/Htmlcuke"
15
+ spec.license = "MIT"
16
+
17
+ spec.add_dependency 'cucumber'
18
+
19
+ spec.post_install_message = <<-EOS
20
+
21
+ -------------------------------------------
22
+ | To use this formatter: |
23
+ | |
24
+ | Add --format 'Htmlcuke::Formatter' to |
25
+ | to your cucumber.yml, Rakefile, or on |
26
+ | the command line after your arguments |
27
+ -------------------------------------------
28
+
29
+ EOS
30
+
31
+ spec.files = `git ls-files -z`.split("\x0")
32
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency 'rake'
37
+ end
@@ -0,0 +1,29 @@
1
+ require 'cucumber/formatter/html'
2
+
3
+ module Htmlcuke
4
+ class Formatter < Cucumber::Formatter::Html
5
+
6
+ def print_messages
7
+ return if @delayed_messages.empty?
8
+
9
+ @delayed_messages.each do |msg|
10
+ @builder.li(:class => 'step message') do
11
+ modified_msg = msg
12
+ modified_msg.to_s.gsub!(/\[[0-9;]*m/, '') # Remove color codes from colorizer/puts for HTML format only
13
+ @builder << modified_msg
14
+ end
15
+ end
16
+ empty_messages
17
+ end
18
+
19
+ def embed_image(src, label)
20
+ id = "img_#{@img_id}"
21
+ @img_id += 1
22
+ @builder.span(:class => 'embed') do |pre|
23
+ pre << %{<a href="" onclick="img=document.getElementById('#{id}'); img.style.display = 'none'; window.open('file://#{src}', '_blank');return false">#{label}</a><br>&nbsp;
24
+ <img id="#{id}" style="display: none" src="#{src}"/>} unless label == 'Screenshot' # if you want the image to show up on the same page change to: img.style.display = (img.style.display == 'none' ? 'block' : 'none')
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Htmlcuke
2
+ VERSION = "1.0.0"
3
+ end
data/lib/htmlcuke.rb ADDED
@@ -0,0 +1 @@
1
+ require 'htmlcuke/formatter'
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: htmlcuke
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Ray
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber
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: rake
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
+ description: ''
42
+ email:
43
+ - ntray1@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - htmlcuke.gemspec
54
+ - lib/htmlcuke.rb
55
+ - lib/htmlcuke/formatter.rb
56
+ - lib/htmlcuke/version.rb
57
+ homepage: https://github.com/maizaAvaro/Htmlcuke
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message: |2+
62
+
63
+ -------------------------------------------
64
+ | To use this formatter: |
65
+ | |
66
+ | Add --format 'Htmlcuke::Formatter' to |
67
+ | to your cucumber.yml, Rakefile, or on |
68
+ | the command line after your arguments |
69
+ -------------------------------------------
70
+
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.2.2
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: See https://github.com/maizaAvaro/Htmlcuke for a description and usage case
90
+ test_files: []