cucumberhtml 0.1.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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +36 -0
- data/Rakefile +32 -0
- data/app/concepts/cucumber_to_html/cell/element.rb +21 -0
- data/app/concepts/cucumber_to_html/cell/feature.rb +52 -0
- data/app/concepts/cucumber_to_html/cell/gherkin.rb +21 -0
- data/app/concepts/cucumber_to_html/cell/scenario.rb +32 -0
- data/app/concepts/cucumber_to_html/cell/step.rb +22 -0
- data/app/concepts/cucumber_to_html/view/element.slim +4 -0
- data/app/concepts/cucumber_to_html/view/feature.slim +6 -0
- data/app/concepts/cucumber_to_html/view/feature_menu_item.slim +2 -0
- data/app/concepts/cucumber_to_html/view/gherkin.slim +17 -0
- data/app/concepts/cucumber_to_html/view/scenario.slim +7 -0
- data/app/concepts/cucumber_to_html/view/step.slim +3 -0
- data/app/controllers/cucumberhtml/application_controller.rb +5 -0
- data/app/controllers/cucumberhtml/cucumber_to_html_controller.rb +11 -0
- data/config/routes.rb +3 -0
- data/lib/cucumberhtml/cell.rb +6 -0
- data/lib/cucumberhtml/engine.rb +5 -0
- data/lib/cucumberhtml/version.rb +3 -0
- data/lib/cucumberhtml.rb +8 -0
- data/lib/tasks/cucumberhtml_tasks.rake +35 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f3ffe9eb3e7f52c8e521f4bed6a7a9093fb5f3da96143730810f40dc8b429552
|
4
|
+
data.tar.gz: 7711e792161c894f6979618d7be656040480a5a866278a3e6da9038ee79d2e27
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a8b58f48b2b2ba4175212261c61cff3077ec37fd52b3250f1716b2d011d874f6fcbb8fe2e338cc8a1884b0450629db18c263c288da2a6a00989cdbe67f9d407
|
7
|
+
data.tar.gz: 37b1536738eb16fa4d46960a023aa14cf02250159495ee83a383c5144d974a90ef26aeca2929fc332d67d35a753ff22772ac856a56a0f428b2060e408fae9fb5
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Erik Axel Nielsen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Cucumberhtml
|
2
|
+
Create nice HTML from cucumber result JSON. As a controller (for test/dev) and a rake task.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
Mount the controller
|
6
|
+
```ruby
|
7
|
+
mount Cucumberhtml::Engine, at: '/cucumber' unless Rails.env.production?
|
8
|
+
```
|
9
|
+
It will by default read results from `tmp/cucumber_result.json`
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
rake cucumberhtml:export[tmp/cucumber_result.json, tmp/cucumber_result2.html]
|
13
|
+
```
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'cucumberhtml', group :development, :test
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
```bash
|
24
|
+
$ bundle
|
25
|
+
```
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
```bash
|
29
|
+
$ gem install cucumberhtml
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
PR are welcome
|
34
|
+
|
35
|
+
## License
|
36
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Cucumberhtml'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
# APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
18
|
+
# load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
# load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'test'
|
28
|
+
t.pattern = 'test/**/*_test.rb'
|
29
|
+
t.verbose = false
|
30
|
+
end
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CucumberToHtml::Cell
|
4
|
+
class Element < Cucumberhtml::Cell
|
5
|
+
def name
|
6
|
+
model['name']
|
7
|
+
end
|
8
|
+
|
9
|
+
def keyword
|
10
|
+
model['keyword']
|
11
|
+
end
|
12
|
+
|
13
|
+
def steps
|
14
|
+
model['steps']
|
15
|
+
end
|
16
|
+
|
17
|
+
def step(step)
|
18
|
+
Step.call(step).call
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CucumberToHtml::Cell
|
4
|
+
class Feature < Cucumberhtml::Cell
|
5
|
+
def feature
|
6
|
+
model
|
7
|
+
end
|
8
|
+
|
9
|
+
def feature_menu_item
|
10
|
+
render :feature_menu_item
|
11
|
+
end
|
12
|
+
|
13
|
+
def active
|
14
|
+
options[:active]
|
15
|
+
end
|
16
|
+
|
17
|
+
def feature_classes
|
18
|
+
'show active' if active
|
19
|
+
end
|
20
|
+
|
21
|
+
def menu_classes
|
22
|
+
"list-group-item list-group-item-action #{'active' if active}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def feature_id
|
26
|
+
"list-#{model['id']}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def name
|
30
|
+
model['name']
|
31
|
+
end
|
32
|
+
|
33
|
+
def description
|
34
|
+
Kramdown::Document.new(model['description']).to_html
|
35
|
+
end
|
36
|
+
|
37
|
+
def element_list
|
38
|
+
model['elements']
|
39
|
+
end
|
40
|
+
|
41
|
+
def element(element)
|
42
|
+
case element['keyword']
|
43
|
+
when 'Scenario'
|
44
|
+
Scenario.call(element).call
|
45
|
+
when 'Background'
|
46
|
+
Element.call(element).call if element == element_list[0]
|
47
|
+
else
|
48
|
+
raise 'Unknown element'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CucumberToHtml::Cell
|
4
|
+
class Gherkin < Cucumberhtml::Cell
|
5
|
+
def feature_menu_list
|
6
|
+
res = '<div class="list-group" id="list-tab" role="tablist">'
|
7
|
+
model.each_with_index do |feature, index|
|
8
|
+
res += Feature.call(feature, active: index == 0).call(:feature_menu_item)
|
9
|
+
end
|
10
|
+
res + '</div>'
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature_list
|
14
|
+
res = '<div class="tab-content" id="nav-tabContent">'
|
15
|
+
model.each_with_index do |feature, index|
|
16
|
+
res += Feature.call(feature, active: index == 0).call
|
17
|
+
end
|
18
|
+
res + '</div>'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CucumberToHtml::Cell
|
4
|
+
class Scenario < Element
|
5
|
+
# class CucumberToHtml::Cell::Scenario < Element
|
6
|
+
def success?
|
7
|
+
model['steps'].all? do |step|
|
8
|
+
step.dig('result', 'status') == 'passed'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def failure?
|
13
|
+
false # TBD
|
14
|
+
end
|
15
|
+
|
16
|
+
def border_classes
|
17
|
+
if success?
|
18
|
+
'border-success'
|
19
|
+
elsif failure?
|
20
|
+
'border-danger'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def body_classes
|
25
|
+
if success?
|
26
|
+
'text-success'
|
27
|
+
elsif failure?
|
28
|
+
'text-danger'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CucumberToHtml::Cell::Step < Cucumberhtml::Cell
|
4
|
+
def keyword
|
5
|
+
model['keyword']
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
model['name']
|
10
|
+
end
|
11
|
+
|
12
|
+
def success?
|
13
|
+
model['result']['status'] == 'passed'
|
14
|
+
end
|
15
|
+
|
16
|
+
def text_classes
|
17
|
+
# Difficult to read
|
18
|
+
# 'text-success' if success?
|
19
|
+
end
|
20
|
+
|
21
|
+
# Others are line, match, duration
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
html
|
2
|
+
head
|
3
|
+
meta charset="utf-8"
|
4
|
+
meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
5
|
+
link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous"
|
6
|
+
script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"
|
7
|
+
script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"
|
8
|
+
script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"
|
9
|
+
title Stories
|
10
|
+
body
|
11
|
+
.container
|
12
|
+
h1 Stories
|
13
|
+
.row
|
14
|
+
.col-3
|
15
|
+
= feature_menu_list
|
16
|
+
.col-9
|
17
|
+
= feature_list
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cucumberhtml
|
4
|
+
class CucumberToHtmlController < ApplicationController
|
5
|
+
def index
|
6
|
+
file = File.read('tmp/cucumber_result.json')
|
7
|
+
json = JSON.parse(file)
|
8
|
+
render html: CucumberToHtml::Cell::Gherkin.call(json)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/config/routes.rb
ADDED
data/lib/cucumberhtml.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module CucumberToHtml
|
2
|
+
end
|
3
|
+
|
4
|
+
require 'cells-rails'
|
5
|
+
|
6
|
+
require_relative '../../app/concepts/cucumber_to_html/cell/gherkin'
|
7
|
+
|
8
|
+
|
9
|
+
namespace :cucumberhtml do
|
10
|
+
task :export, [:filename, :outfile] => :environment do |_t, args|
|
11
|
+
desc 'Exporting cucumber html'
|
12
|
+
filename = args[:filename] || 'tmp/cucumber_result.json'
|
13
|
+
outfile = args[:outfile] || 'tmp/cucumber_result.html'
|
14
|
+
|
15
|
+
file = File.read(filename)
|
16
|
+
json = JSON.parse(file)
|
17
|
+
html = CucumberToHtml::Cell::Gherkin.call(json)
|
18
|
+
open(outfile, 'w') do |f|
|
19
|
+
f << html
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# task export3: :environment, :filename do |_t, args|
|
24
|
+
# desc 'Exporting cucumber html'
|
25
|
+
# filename ='tmp/cucumber_result.json'
|
26
|
+
# outfile = 'tmp/cucumber_result.html'
|
27
|
+
#
|
28
|
+
# file = File.read(filename)
|
29
|
+
# json = JSON.parse(file)
|
30
|
+
# html = CucumberToHtml::Cell::Gherkin.call(json)
|
31
|
+
# open(outfile, 'w') do |f|
|
32
|
+
# f << html
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumberhtml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erik Axel Nielsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cells-rails
|
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: cells-slim
|
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: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: trailblazer-cells
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Cucumber to HTML converter.
|
70
|
+
email:
|
71
|
+
- erikaxel@lucalabs.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- README.md
|
78
|
+
- Rakefile
|
79
|
+
- app/concepts/cucumber_to_html/cell/element.rb
|
80
|
+
- app/concepts/cucumber_to_html/cell/feature.rb
|
81
|
+
- app/concepts/cucumber_to_html/cell/gherkin.rb
|
82
|
+
- app/concepts/cucumber_to_html/cell/scenario.rb
|
83
|
+
- app/concepts/cucumber_to_html/cell/step.rb
|
84
|
+
- app/concepts/cucumber_to_html/view/element.slim
|
85
|
+
- app/concepts/cucumber_to_html/view/feature.slim
|
86
|
+
- app/concepts/cucumber_to_html/view/feature_menu_item.slim
|
87
|
+
- app/concepts/cucumber_to_html/view/gherkin.slim
|
88
|
+
- app/concepts/cucumber_to_html/view/scenario.slim
|
89
|
+
- app/concepts/cucumber_to_html/view/step.slim
|
90
|
+
- app/controllers/cucumberhtml/application_controller.rb
|
91
|
+
- app/controllers/cucumberhtml/cucumber_to_html_controller.rb
|
92
|
+
- config/routes.rb
|
93
|
+
- lib/cucumberhtml.rb
|
94
|
+
- lib/cucumberhtml/cell.rb
|
95
|
+
- lib/cucumberhtml/engine.rb
|
96
|
+
- lib/cucumberhtml/version.rb
|
97
|
+
- lib/tasks/cucumberhtml_tasks.rake
|
98
|
+
homepage: https://www.github.com/lucalabs/cucumberhtml
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubyforge_project:
|
118
|
+
rubygems_version: 2.7.3
|
119
|
+
signing_key:
|
120
|
+
specification_version: 4
|
121
|
+
summary: Cucumber to HTML converter.
|
122
|
+
test_files: []
|