cuke_sniffer 1.0.1 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b53fd2a4aa90a0c9a77360600b64f0d5a8317d88
|
4
|
+
data.tar.gz: b801e304f3cfca26540c38e01046e551f1de7814
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 785c6e575269118fe0aa09d13f24e90a47d791dd94a20c2d45a44e2eb2dbd0fd2fde67e63a60b097cab09c337dcdaa8a6ad7fcf9a7bf1a41877c6619d9f32302
|
7
|
+
data.tar.gz: fc488ea1e58617e8d3973fdc0ca8145524da4607f0c2f10ae84f1cd98cfb36f34b1c1f61f13fb00058ce910f7e826a918a772087882d9810d70c7cd43876553e
|
@@ -13,9 +13,9 @@ module CukeSniffer
|
|
13
13
|
def self.output_console(cuke_sniffer)
|
14
14
|
summary = cuke_sniffer.summary
|
15
15
|
output = "Suite Summary" +
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
" Total Score: #{summary[:total_score]}\n" +
|
17
|
+
get_output_summary_nodes(cuke_sniffer) +
|
18
|
+
console_improvement_list(summary[:improvement_list])
|
19
19
|
|
20
20
|
puts output
|
21
21
|
end
|
@@ -32,9 +32,9 @@ module CukeSniffer
|
|
32
32
|
# Formats the section data for a summary object
|
33
33
|
def self.console_summary(name, summary)
|
34
34
|
" #{name}\n" +
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
" Min: #{summary[:min]}\n" +
|
36
|
+
" Max: #{summary[:max]}\n" +
|
37
|
+
" Average: #{summary[:average]}\n"
|
38
38
|
end
|
39
39
|
|
40
40
|
# Formats the improvement list data for summary
|
@@ -55,7 +55,9 @@ module CukeSniffer
|
|
55
55
|
def self.output_html(cuke_sniffer, file_name = DEFAULT_OUTPUT_FILE_NAME, template_name = "standard_template")
|
56
56
|
cuke_sniffer = sort_cuke_sniffer_lists(cuke_sniffer)
|
57
57
|
output = ERB.new(extract_markup("#{template_name}.html.erb")).result(binding)
|
58
|
-
File.open(format_html_file_name(file_name), 'w') do |f|
|
58
|
+
File.open(format_html_file_name(file_name), 'w') do |f|
|
59
|
+
f.write(output)
|
60
|
+
end
|
59
61
|
end
|
60
62
|
|
61
63
|
# Returns an ERB page built up for the passed file name
|
@@ -102,7 +104,9 @@ module CukeSniffer
|
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
|
-
# Creates an xml file in the junit with issues organized by file.
|
107
|
+
# Creates an xml file that can be read by Jenkins/Hudson in the junit format with issues organized and collated by file.
|
108
|
+
# Each file becomes a testsuite with corresponding failures associated to it.
|
109
|
+
# If no failures are found this will be marked as a pass by Jenkins/Hudson.
|
106
110
|
# file_name defaults to "cuke_sniffer_result.xml" unless specified
|
107
111
|
# cuke_sniffer.output_xml
|
108
112
|
# Or
|
@@ -111,34 +115,47 @@ module CukeSniffer
|
|
111
115
|
file_name = file_name + ".xml" unless file_name =~ /\.xml$/
|
112
116
|
results = {}
|
113
117
|
failures = 0
|
118
|
+
suits={}
|
114
119
|
current = cuke_sniffer.features
|
115
120
|
current.concat cuke_sniffer.scenarios
|
116
121
|
current.concat cuke_sniffer.step_definitions
|
117
122
|
current.concat cuke_sniffer.hooks
|
118
123
|
current.each do |test|
|
119
124
|
location = test.location.gsub("#{Dir.pwd}/", '')
|
120
|
-
location_no_line = location.gsub(/:[0-9]*/,'')
|
125
|
+
location_no_line = location.gsub(/:[0-9]*/, '')
|
121
126
|
line_num = location.include?(":") ? location.gsub(/.*:(.*)/, "\\1") : "full_file"
|
122
|
-
errors = test.rules_hash.keys.map {|f| {:line => line_num,
|
123
|
-
|
124
|
-
|
125
|
-
|
127
|
+
errors = test.rules_hash.keys.map { |f| {:line => "line: #{line_num}",
|
128
|
+
:error => f,
|
129
|
+
:formatted => "Location: #{location}",
|
130
|
+
:instances => "Instances: #{test.rules_hash[f]}"
|
131
|
+
} }
|
126
132
|
results[location_no_line] = results[location_no_line].nil? ? errors : results[location_no_line].concat(errors)
|
127
133
|
failures += test.rules_hash.size
|
128
134
|
end
|
135
|
+
results.each do |location, failure|
|
136
|
+
suits[location]=failure
|
137
|
+
end
|
129
138
|
builder = Nokogiri::XML::Builder.new do |xml|
|
130
139
|
xml.testsuites(:tests => results.size, :failures => failures) do
|
131
|
-
|
132
|
-
failures.
|
133
|
-
|
134
|
-
xml.
|
140
|
+
suits.each do |location, failures|
|
141
|
+
xml.testsuite(:name => location, :tests => 1, :failures => failures.length) do
|
142
|
+
if failures.length == 0
|
143
|
+
xml.testcase(:classname => location, :name => location, :time => 0, :status => 0)
|
144
|
+
else
|
145
|
+
failures.each do |failure|
|
146
|
+
xml.testcase(:classname => location, :name => failure[:line], :time => 0, :status => failure[:instances]) do
|
147
|
+
xml.failure(failure[:formatted], :type => 'failure', :message => "#{failure[:error]} #{failure[:instances]}")
|
148
|
+
end
|
149
|
+
end
|
135
150
|
end
|
136
151
|
end
|
137
152
|
end
|
138
153
|
end
|
139
154
|
end
|
140
155
|
output = builder.to_xml
|
141
|
-
File.open(file_name, 'w') do |f|
|
156
|
+
File.open(file_name, 'w') do |f|
|
157
|
+
f.write(output)
|
158
|
+
end
|
142
159
|
# Return here to aid testing.
|
143
160
|
output
|
144
161
|
end
|
@@ -101,10 +101,7 @@
|
|
101
101
|
<% next if scenario.score == 0 %>
|
102
102
|
<div class="col-md-12 scenario">
|
103
103
|
<div class="col-md-12 title">
|
104
|
-
|
105
|
-
View <span class="glyphicon glyphicon-eye-open"></span>
|
106
|
-
</div>
|
107
|
-
<%= scenario.type %>: <%=scenario.name %>
|
104
|
+
<%= scenario.type %>: <%=scenario.name %> (line: <%=scenario.start_line %>)
|
108
105
|
</div>
|
109
106
|
<div class="col-md-12 details well">
|
110
107
|
<% SummaryHelper::sort_improvement_list(scenario.rules_hash).each do |phrase, count| %>
|
@@ -129,4 +126,4 @@
|
|
129
126
|
<% end %>
|
130
127
|
</div>
|
131
128
|
</div>
|
132
|
-
</div>
|
129
|
+
</div>
|
@@ -53,11 +53,16 @@ module CukeSniffer
|
|
53
53
|
lambda { |feature_rule_target, rule|
|
54
54
|
tokens = feature_rule_target.tags.collect { |line| line.split }.flatten
|
55
55
|
|
56
|
+
return_value = nil
|
57
|
+
|
56
58
|
tokens.each_with_index do |token, index|
|
57
59
|
if feature_rule_target.is_comment?(token) && tokens[0...index].any? { |x| x =~ /\A@/ }
|
58
|
-
|
60
|
+
return_value = feature_rule_target.store_rule(rule)
|
61
|
+
break
|
59
62
|
end
|
60
63
|
end
|
64
|
+
|
65
|
+
return_value
|
61
66
|
}
|
62
67
|
},
|
63
68
|
:universal_nested_step => {
|
@@ -198,11 +203,14 @@ module CukeSniffer
|
|
198
203
|
:score => WARNING,
|
199
204
|
:targets => ["Scenario"],
|
200
205
|
:reason => lambda { |scenario, rule| step_order = scenario.get_step_order
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
+
if !step_order.empty?
|
207
|
+
["But", "*", "And"].each { |type| step_order.delete(type) }
|
208
|
+
step_order = step_order.chunk { |keyword| keyword }.map(&:first)
|
209
|
+
if(step_order != %w(Given When Then) and step_order != %w(When Then))
|
210
|
+
scenario.store_rule(rule)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
}
|
206
214
|
},
|
207
215
|
:invalid_first_step => {
|
208
216
|
:enabled => true,
|
@@ -315,7 +323,7 @@ module CukeSniffer
|
|
315
323
|
:score => WARNING,
|
316
324
|
:targets => ["Feature", "Scenario"],
|
317
325
|
:reason => lambda { |feature_rule_target, rule| feature_rule_target.tags.each do | tag |
|
318
|
-
feature_rule_target.store_rule(rule, rule.phrase.gsub("{class}", feature_rule_target.type)) if feature_rule_target.
|
326
|
+
feature_rule_target.store_rule(rule, rule.phrase.gsub("{class}", feature_rule_target.type)) if feature_rule_target.is_comment_and_tag?(tag)
|
319
327
|
end}
|
320
328
|
},
|
321
329
|
:empty_hook => {
|
@@ -347,6 +355,16 @@ module CukeSniffer
|
|
347
355
|
all_tags.flatten!
|
348
356
|
unique_tags = all_tags.uniq
|
349
357
|
true unless all_tags == unique_tags}
|
358
|
+
},
|
359
|
+
:duplicate_scenario_name => {
|
360
|
+
:enabled => true,
|
361
|
+
:phrase => "Feature has scenarios with the same name.",
|
362
|
+
:score => WARNING,
|
363
|
+
:targets => ["Feature"],
|
364
|
+
:reason => lambda { |feature, rule|
|
365
|
+
names = feature.scenarios.collect { |scenario| scenario.name }
|
366
|
+
return names.length > names.uniq.length
|
367
|
+
}
|
350
368
|
}
|
351
369
|
}
|
352
370
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_sniffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Cochran
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|