cornucopia 0.1.20 → 0.1.21
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/cornucopia/cucumber_hooks.rb +92 -20
- data/lib/cornucopia/util/configuration.rb +55 -0
- data/lib/cornucopia/util/configured_report.rb +23 -5
- data/lib/cornucopia/util/report_builder.rb +35 -14
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/util/report_builder_spec.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df8ca3046295b778c73f4422cddec24ecdc92e11
|
4
|
+
data.tar.gz: 1a1e0632e7bf439078e67e06a083401bd3861e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b96c1ee70f6264b86871f8afe5662c2ce1bff0a4e47b207105b6618f93718d9c50367933b2dcde212b807cc7dbc39019b253908811336b441419ec0bed7763d
|
7
|
+
data.tar.gz: 37b84256e2d5ede37af744e73eb0c5d223f4e414d9f947f29470d4ac2b6a9e0abbff6db8e0a4533e602ce81b5f55306194e217da075add1cd299ff96f06efe70
|
@@ -2,36 +2,108 @@ require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
|
|
2
2
|
load ::File.expand_path("capybara/install_finder_extensions.rb", File.dirname(__FILE__))
|
3
3
|
load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
if Cucumber::VERSION.split[0].to_i >= 2
|
6
|
+
Around do |scenario, block|
|
7
|
+
seed_value = Cornucopia::Util::Configuration.seed ||
|
8
|
+
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
8
9
|
|
9
|
-
|
10
|
+
scenario.instance_variable_set :@seed_value, seed_value
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
13
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
test_name = ""
|
16
|
+
if scenario.respond_to?(:feature)
|
17
|
+
test_name = "#{scenario.feature.title} : #{scenario.title}"
|
18
|
+
elsif scenario.respond_to?(:line)
|
19
|
+
test_name = "Scenario - Line: #{scenario.line}"
|
20
|
+
else
|
21
|
+
test_name = "Scenario - Unknown"
|
22
|
+
end
|
23
|
+
Cornucopia::Util::ReportBuilder.current_report.within_test(test_name) do
|
24
|
+
block.call
|
25
|
+
end
|
26
|
+
|
27
|
+
if scenario.failed?
|
28
|
+
seed_value = scenario.instance_variable_get(:@seed_value)
|
29
|
+
puts ("random seed for testing was: #{seed_value}")
|
30
|
+
|
31
|
+
report_name = ""
|
32
|
+
if scenario.respond_to?(:feature)
|
33
|
+
report_name = "Test Error: #{scenario.feature.title}:#{scenario.title}"
|
34
|
+
else
|
35
|
+
report_name = "Line - #{scenario.line}"
|
36
|
+
end
|
37
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section(report_name) do |report|
|
38
|
+
configured_report = nil
|
39
|
+
if scenario.respond_to?(:feature)
|
40
|
+
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
41
|
+
else
|
42
|
+
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber_outline
|
43
|
+
end
|
44
|
+
|
45
|
+
configured_report.add_report_objects scenario: scenario, cucumber: self
|
46
|
+
configured_report.generate_report(report)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
50
|
+
end
|
51
|
+
|
52
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
53
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
16
54
|
end
|
55
|
+
else
|
56
|
+
Before do |scenario, block|
|
57
|
+
seed_value = Cornucopia::Util::Configuration.seed ||
|
58
|
+
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
17
59
|
|
18
|
-
|
19
|
-
seed_value = scenario.instance_variable_get(:@seed_value)
|
20
|
-
puts ("random seed for testing was: #{seed_value}")
|
60
|
+
scenario.instance_variable_set :@seed_value, seed_value
|
21
61
|
|
22
|
-
Cornucopia::
|
23
|
-
|
24
|
-
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
62
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
63
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
25
64
|
|
26
|
-
|
27
|
-
|
65
|
+
test_name = ""
|
66
|
+
if scenario.respond_to?(:feature)
|
67
|
+
test_name = "#{scenario.feature.title} : #{scenario.title}"
|
68
|
+
elsif scenario.respond_to?(:line)
|
69
|
+
test_name = "Scenario - Line: #{scenario.line}"
|
70
|
+
else
|
71
|
+
test_name = "Scenario - Unknown"
|
28
72
|
end
|
29
|
-
|
30
|
-
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
73
|
+
Cornucopia::Util::ReportBuilder.current_report.start_test(scenario, test_name)
|
31
74
|
end
|
32
75
|
|
33
|
-
|
34
|
-
|
76
|
+
After do |scenario, block|
|
77
|
+
if scenario.failed?
|
78
|
+
seed_value = scenario.instance_variable_get(:@seed_value)
|
79
|
+
puts ("random seed for testing was: #{seed_value}")
|
80
|
+
|
81
|
+
report_name = ""
|
82
|
+
if scenario.respond_to?(:feature)
|
83
|
+
report_name = "Test Error: #{scenario.feature.title}:#{scenario.title}"
|
84
|
+
else
|
85
|
+
report_name = "Line - #{scenario.line}"
|
86
|
+
end
|
87
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section(report_name) do |report|
|
88
|
+
configured_report = nil
|
89
|
+
if scenario.respond_to?(:feature)
|
90
|
+
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
91
|
+
else
|
92
|
+
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber_outline
|
93
|
+
end
|
94
|
+
|
95
|
+
configured_report.add_report_objects scenario: scenario, cucumber: self
|
96
|
+
configured_report.generate_report(report)
|
97
|
+
end
|
98
|
+
else
|
99
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
100
|
+
end
|
101
|
+
|
102
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
103
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
104
|
+
|
105
|
+
Cornucopia::Util::ReportBuilder.current_report.end_test(scenario)
|
106
|
+
end
|
35
107
|
end
|
36
108
|
|
37
109
|
at_exit do
|
@@ -129,6 +129,61 @@ module Cornucopia
|
|
129
129
|
:cucumber__integration_session
|
130
130
|
]
|
131
131
|
},
|
132
|
+
cucumber_outline: {
|
133
|
+
min_fields: [
|
134
|
+
{
|
135
|
+
report_element: :scenario__scenario_outline__name,
|
136
|
+
report_options: { label: "feature_outline" }
|
137
|
+
},
|
138
|
+
{
|
139
|
+
report_element: :scenario__name,
|
140
|
+
report_options: { label: "scenario_example" }
|
141
|
+
},
|
142
|
+
{
|
143
|
+
report_element: :scenario__scenario_outline__example_sections__0__0__0,
|
144
|
+
# report_options: { format: ->(value) { "#{value.file}:#{value.line}" } }
|
145
|
+
report_options: { format_object: Cornucopia::Util::CucumberFormatter,
|
146
|
+
format_function: :format_location }
|
147
|
+
},
|
148
|
+
:scenario__exception__to_s,
|
149
|
+
:scenario__exception__backtrace
|
150
|
+
],
|
151
|
+
more_info_fields: [
|
152
|
+
:scenario__exception__class__name,
|
153
|
+
:scenario,
|
154
|
+
:scenario__scenario_outline__example_sections__0__1__comments,
|
155
|
+
:scenario__scenario_outline__example_sections__0__1__keyword,
|
156
|
+
:scenario__scenario_outline__example_sections__0__1__description,
|
157
|
+
:scenario__source_tag_names,
|
158
|
+
:scenario__scenario_outline__example_sections__0__1__tags,
|
159
|
+
:scenario__scenario_outline__example_sections__0__0,
|
160
|
+
:scenario__scenario_outline,
|
161
|
+
:cucumber,
|
162
|
+
:logs,
|
163
|
+
:capybara_page_diagnostics
|
164
|
+
],
|
165
|
+
expand_fields: [
|
166
|
+
:scenario,
|
167
|
+
:scenario__scenario_outline,
|
168
|
+
:cucumber,
|
169
|
+
],
|
170
|
+
expand_inline_fields: [
|
171
|
+
],
|
172
|
+
exclude_fields: [
|
173
|
+
:scenario__background,
|
174
|
+
:scenario__scenario_outline__background,
|
175
|
+
:scenario__table,
|
176
|
+
:scenario__feature,
|
177
|
+
:scenario__current_visitor,
|
178
|
+
:scenario__raw_steps,
|
179
|
+
:scenario__title,
|
180
|
+
:cucumber____cucumber_runtime,
|
181
|
+
:cucumber____natural_language,
|
182
|
+
:cucumber___rack_test_sessions,
|
183
|
+
:cucumber___rack_mock_sessions,
|
184
|
+
:cucumber__integration_session
|
185
|
+
]
|
186
|
+
},
|
132
187
|
spinach: {
|
133
188
|
min_fields: [
|
134
189
|
:failure_description,
|
@@ -290,6 +290,7 @@ module Cornucopia
|
|
290
290
|
def export_field_record(export_field, parent_object, parent_object_name, report_table, level, options = {})
|
291
291
|
parent_expanded = options.delete(:expanded_field)
|
292
292
|
report_object = nil
|
293
|
+
reported = false
|
293
294
|
|
294
295
|
if (options.delete(:report_object_set))
|
295
296
|
report_object = parent_object
|
@@ -298,14 +299,21 @@ module Cornucopia
|
|
298
299
|
(!parent_object.methods.include?(export_field[:report_element][level]) ||
|
299
300
|
parent_object.method(export_field[:report_element][level]).parameters.empty?)
|
300
301
|
report_object = parent_object.send(export_field[:report_element][level])
|
302
|
+
reported = true
|
301
303
|
elsif parent_object.respond_to?(:[])
|
302
304
|
key_value = export_field[:report_element][level]
|
303
305
|
if key_value.to_s =~ /^-?[0-9]+$/
|
304
306
|
key_value = key_value.to_s.to_i
|
305
307
|
end
|
306
308
|
|
307
|
-
|
308
|
-
|
309
|
+
begin
|
310
|
+
report_object = parent_object.send(:[], key_value)
|
311
|
+
reported = true
|
312
|
+
rescue
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
unless reported
|
309
317
|
instance_variable_name = instance_variables_contain(parent_object, export_field[:report_element][level])
|
310
318
|
|
311
319
|
if instance_variable_name
|
@@ -515,11 +523,21 @@ module Cornucopia
|
|
515
523
|
end
|
516
524
|
|
517
525
|
def get_instance_variable(the_object, instance_variable, variable_name)
|
526
|
+
fetched = false
|
527
|
+
|
518
528
|
if the_object.respond_to?(variable_name)
|
519
|
-
|
520
|
-
|
521
|
-
|
529
|
+
begin
|
530
|
+
return_value = the_object.send(variable_name)
|
531
|
+
fetched = true
|
532
|
+
rescue
|
533
|
+
end
|
522
534
|
end
|
535
|
+
|
536
|
+
unless fetched
|
537
|
+
return_value = the_object.instance_variable_get(instance_variable)
|
538
|
+
end
|
539
|
+
|
540
|
+
return_value
|
523
541
|
end
|
524
542
|
end
|
525
543
|
end
|
@@ -12,6 +12,9 @@ module Cornucopia
|
|
12
12
|
|
13
13
|
MAX_OLD_FOLDERS = 5
|
14
14
|
|
15
|
+
class TestDataHolder
|
16
|
+
end
|
17
|
+
|
15
18
|
class << self
|
16
19
|
def current_report(folder_name = nil, parent_folder = nil)
|
17
20
|
if (@@current_report &&
|
@@ -101,8 +104,7 @@ module Cornucopia
|
|
101
104
|
rescue Timeout::Error
|
102
105
|
timed_out = true
|
103
106
|
end
|
104
|
-
rescue Exception
|
105
|
-
error.to_s
|
107
|
+
rescue Exception
|
106
108
|
end
|
107
109
|
|
108
110
|
# If it timed out or threw an exception, try .to_s
|
@@ -114,6 +116,8 @@ module Cornucopia
|
|
114
116
|
end
|
115
117
|
rescue Timeout::Error
|
116
118
|
return_value = "Timed out rendering"
|
119
|
+
rescue => error
|
120
|
+
return_value = "Rendering error => #{error.to_s}\n#{error.backtrace.join("\n")}"
|
117
121
|
end
|
118
122
|
end
|
119
123
|
|
@@ -495,24 +499,41 @@ module Cornucopia
|
|
495
499
|
end
|
496
500
|
end
|
497
501
|
|
502
|
+
def start_test(stack_object, test_name)
|
503
|
+
test_data =
|
504
|
+
{
|
505
|
+
orig_test_name: @test_name,
|
506
|
+
orig_test_folder: @report_test_folder_name,
|
507
|
+
orig_test_list_item: @test_list_item,
|
508
|
+
orig_section_number: @section_number
|
509
|
+
}
|
510
|
+
|
511
|
+
stack_object.instance_variable_set(:@report_builder_test_start_data, test_data)
|
512
|
+
|
513
|
+
@test_name = test_name
|
514
|
+
@report_test_folder_name = nil
|
515
|
+
@test_list_item = nil
|
516
|
+
@section_number = 0
|
517
|
+
end
|
518
|
+
|
519
|
+
def end_test(stack_object)
|
520
|
+
test_data = stack_object.instance_variable_get(:@report_builder_test_start_data)
|
521
|
+
|
522
|
+
@section_number = test_data[:orig_section_number]
|
523
|
+
@test_name = test_data[:orig_test_name]
|
524
|
+
@report_test_folder_name = test_data[:orig_test_folder]
|
525
|
+
@test_list_item = test_data[:orig_test_list_item]
|
526
|
+
end
|
527
|
+
|
498
528
|
def within_test(test_name, &block)
|
499
|
-
|
500
|
-
orig_test_folder = @report_test_folder_name
|
501
|
-
orig_test_list_item = @test_list_item
|
502
|
-
orig_section_number = @section_number
|
529
|
+
test_data_holder = TestDataHolder.new
|
503
530
|
|
504
531
|
begin
|
505
|
-
|
506
|
-
@report_test_folder_name = nil
|
507
|
-
@test_list_item = nil
|
508
|
-
@section_number = 0
|
532
|
+
start_test(test_data_holder, test_name)
|
509
533
|
|
510
534
|
block.yield
|
511
535
|
ensure
|
512
|
-
|
513
|
-
@test_name = orig_test_name
|
514
|
-
@report_test_folder_name = orig_test_folder
|
515
|
-
@test_list_item = orig_test_list_item
|
536
|
+
end_test(test_data_holder)
|
516
537
|
end
|
517
538
|
end
|
518
539
|
|
data/lib/cornucopia/version.rb
CHANGED
@@ -215,6 +215,16 @@ describe Cornucopia::Util::ReportBuilder do
|
|
215
215
|
expect(Cornucopia::Util::ReportBuilder.pretty_object(test_object)).to be == "{:a=>\"b\"}"
|
216
216
|
end
|
217
217
|
|
218
|
+
it "deals with exceptions" do
|
219
|
+
test_object = { a: "b" }
|
220
|
+
|
221
|
+
expect(test_object).to receive(:pretty_inspect) { raise "this is an error" }
|
222
|
+
expect(test_object).to receive(:to_s) { raise "this is an error" }
|
223
|
+
expect(Cornucopia::Util::ReportBuilder).not_to receive(:pretty_array)
|
224
|
+
|
225
|
+
expect(Cornucopia::Util::ReportBuilder.pretty_object(test_object)).to match /Rendering error =\>/
|
226
|
+
end
|
227
|
+
|
218
228
|
it "times out after a long time with t_s too" do
|
219
229
|
test_object = { a: "b" }
|
220
230
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cornucopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|