suiteview 2.1.1 → 2.1.4
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/suiteview.rb +60 -35
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '06679e0b83b8b947e67035ac24b79b77a8742dff0dd7c51420969ef88d550dfd'
|
4
|
+
data.tar.gz: a63fa95ad432ed7e3c7b2b8e7fe9d87da08d7629a737323b915850d50a8f45fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4ffd0d280edd235691fb5a800025309a6fdf69ca016fd582354f7d20784295cc5a35cfb647e016f40ce5df77d2a05004ffba2eca320a3f336e9d052ce41944a
|
7
|
+
data.tar.gz: aeaf77255c85d7bf60c78261bfd691e60942dfcdbda23405e792025f88c3730ddb03b328b0e74a748d315bcc6594bf2423be323b432919576b76988d4d65c233
|
data/lib/suiteview.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
require 'cql'
|
2
|
-
|
2
|
+
require_relative './suitestat'
|
3
|
+
require_relative './suiterender'
|
4
|
+
# SuiteView is responsible for providing consumable Ruby Cucumber suite stats
|
3
5
|
class SuiteView
|
4
|
-
attr_accessor :repo, :include_tags, :output
|
6
|
+
attr_accessor :repo, :include_tags, :output, :render_step
|
7
|
+
|
5
8
|
def initialize(opts)
|
6
9
|
self.output = nil
|
7
10
|
self.repo = CQL::Repository.new(opts[:repo])
|
8
|
-
self.include_tags = opts[:include_tags]
|
11
|
+
self.include_tags = opts[:include_tags] || ""
|
12
|
+
self.include_tags = self.include_tags.split(',')
|
13
|
+
|
14
|
+
# Create a SuiteRender object and set it as the last step in the chain
|
15
|
+
self.render_step = SuiteRender.new(self)
|
16
|
+
render_step.next_step = self
|
9
17
|
end
|
10
18
|
|
11
19
|
def outline_tag_count(tag)
|
12
|
-
self.output =
|
13
|
-
select examples
|
14
|
-
transform examples => lambda {|examples| examples[0].rows.drop(1) }
|
15
|
-
from outlines
|
16
|
-
with { |outline| outline.tags.map(&:name).include?(tag)}
|
17
|
-
end.map {|item| item['examples']}.flatten.count
|
20
|
+
self.output = outline_query(tag).map { |item| item['examples'] }.flatten.count
|
18
21
|
self
|
19
22
|
end
|
20
23
|
|
21
24
|
def scenario_tag_count(tag)
|
22
|
-
self.output =
|
23
|
-
select name
|
24
|
-
from scenarios
|
25
|
-
with { |scenario| scenario.tags.map(&:name).include?(tag)}
|
26
|
-
end.map {|item| item['name']}.count
|
25
|
+
self.output = scenario_query(tag).map { |item| item['name'] }.count
|
27
26
|
self
|
28
27
|
end
|
29
28
|
|
@@ -34,7 +33,7 @@ class SuiteView
|
|
34
33
|
|
35
34
|
def total_tags_count
|
36
35
|
output = [%w(tag count)]
|
37
|
-
self.include_tags.
|
36
|
+
self.include_tags.each do |tag|
|
38
37
|
output << [tag, total_tag_count(tag).render.to_s]
|
39
38
|
end
|
40
39
|
self.output = output
|
@@ -42,36 +41,62 @@ class SuiteView
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def percentages
|
45
|
-
|
46
|
-
|
47
|
-
tag_counts = {}
|
48
|
-
self.include_tags.split(',').each do |include_tag|
|
49
|
-
total_count += total_tag_count(include_tag).render
|
50
|
-
tag_counts[include_tag] = total_tag_count(include_tag).render
|
51
|
-
end
|
52
|
-
self.include_tags.split(',').each do |include_tag|
|
53
|
-
output << [include_tag, ((tag_counts[include_tag]/total_count.to_f)*100).to_s]
|
54
|
-
end
|
55
|
-
self.output = output
|
44
|
+
suite_stat_dto = SuiteStat.new([%w(tag percent)], 0, {})
|
45
|
+
self.output = calc_percentage(suite_stat_dto)
|
56
46
|
self
|
57
47
|
end
|
58
48
|
|
59
49
|
def to_csv
|
60
|
-
self.
|
61
|
-
self.output.each do |row|
|
62
|
-
csv << row
|
63
|
-
end
|
64
|
-
end
|
65
|
-
self
|
50
|
+
self.render_step.to_csv
|
66
51
|
end
|
67
52
|
|
68
53
|
def render
|
69
|
-
self.
|
54
|
+
self.render_step.render
|
70
55
|
end
|
71
56
|
|
72
57
|
def render_to_file(filename)
|
73
|
-
|
74
|
-
|
58
|
+
self.render_step.render_to_file(filename)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def calc_percentage(suite_stat_dto)
|
64
|
+
suite_stat_dto.total_count = calc_percentage_totals(suite_stat_dto)
|
65
|
+
collate_percentage_rows(suite_stat_dto)
|
66
|
+
end
|
67
|
+
|
68
|
+
def collate_percentage_rows(suite_stat_dto)
|
69
|
+
output = suite_stat_dto.output
|
70
|
+
self.include_tags.each do |include_tag|
|
71
|
+
output << [include_tag, ((suite_stat_dto.tag_counts[include_tag] / suite_stat_dto.total_count.to_f) * 100).to_s]
|
72
|
+
end
|
73
|
+
output
|
74
|
+
end
|
75
|
+
|
76
|
+
def calc_percentage_totals(suite_stat_dto)
|
77
|
+
total_count = suite_stat_dto.total_count
|
78
|
+
self.include_tags.each do |include_tag|
|
79
|
+
count_for_tag = total_tag_count(include_tag)
|
80
|
+
total_count += count_for_tag.render
|
81
|
+
suite_stat_dto.tag_counts[include_tag] = count_for_tag.render
|
82
|
+
end
|
83
|
+
total_count
|
84
|
+
end
|
85
|
+
|
86
|
+
def outline_query(tag)
|
87
|
+
self.repo.query do
|
88
|
+
select examples
|
89
|
+
transform examples => lambda { |examples| examples[0].rows.drop(1) }
|
90
|
+
from outlines
|
91
|
+
with { |outline| outline.tags.map(&:name).include?(tag) }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def scenario_query(tag)
|
96
|
+
self.repo.query do
|
97
|
+
select name
|
98
|
+
from scenarios
|
99
|
+
with { |scenario| scenario.tags.map(&:name).include?(tag) }
|
75
100
|
end
|
76
101
|
end
|
77
102
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: suiteview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David West
|
@@ -66,8 +66,50 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
-
description:
|
70
|
-
your unique specifications
|
69
|
+
description: |
|
70
|
+
suiteview is a tool to help show the contents of a cucumber suite with your unique specifications
|
71
|
+
|
72
|
+
`my_suiteview.rb`
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
require "suiteview"
|
76
|
+
|
77
|
+
# Instantiate the SuiteView class and give it the location of your Cucumber Suite (repo)
|
78
|
+
sv = SuiteView.new({repo: "features", include_tags: "@tweets,@followers"})
|
79
|
+
|
80
|
+
# Get a count of all Scenarios directly tagged with a particular tag
|
81
|
+
sv.percentages.to_csv.render_to_file("my.csv")
|
82
|
+
```
|
83
|
+
|
84
|
+
And you'll have your output
|
85
|
+
|
86
|
+
`my.csv`
|
87
|
+
|
88
|
+
```csv
|
89
|
+
tag,percent
|
90
|
+
@tweets,80.0
|
91
|
+
@followers,20.0
|
92
|
+
```
|
93
|
+
|
94
|
+
`my_suiteview2.rb`
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
require "suiteview"
|
98
|
+
|
99
|
+
# Instantiate the SuiteView class and give it the location of your Cucumber Suite (repo)
|
100
|
+
sv = SuiteView.new({repo: "features", include_tags: "@tweets,@followers"})
|
101
|
+
|
102
|
+
# Get a count of all Scenarios directly tagged with a particular tag
|
103
|
+
sv.total_tags_count.to_csv.render_to_file("my2.csv")
|
104
|
+
```
|
105
|
+
|
106
|
+
`my2.csv`
|
107
|
+
|
108
|
+
```csv
|
109
|
+
tag,count
|
110
|
+
@tweets,4
|
111
|
+
@followers,1
|
112
|
+
```
|
71
113
|
email: support@suiteview.xyz
|
72
114
|
executables: []
|
73
115
|
extensions: []
|