cornucopia 0.1.18 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cornucopia/capybara/finder_diagnostics.rb +1 -0
- data/lib/cornucopia/capybara/install_matcher_extensions.rb +4 -0
- data/lib/cornucopia/capybara/matcher_extensions.rb +24 -1
- data/lib/cornucopia/cucumber_hooks.rb +5 -14
- data/lib/cornucopia/rspec_hooks.rb +10 -1
- data/lib/cornucopia/source_files/report.js +11 -2
- data/lib/cornucopia/source_files/report_holder.html +2 -2
- data/lib/cornucopia/spinach_hooks.rb +18 -21
- data/lib/cornucopia/util/configuration.rb +78 -17
- data/lib/cornucopia/util/configured_report.rb +27 -7
- data/lib/cornucopia/util/report_builder.rb +19 -1
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/capybara/matcher_extensions_spec.rb +39 -8
- data/spec/lib/util/configuration_spec.rb +66 -0
- data/spec/lib/util/configured_report_spec.rb +45 -3
- data/spec/lib/util/report_builder_spec.rb +84 -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: 27a9d88236b2e8ca285adbca01be518df0e2ae41
|
4
|
+
data.tar.gz: 6056d4a64c9d77c37891438ec10299728f8accbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73d21c4b62f1f35d9025b5b2480b30e14f6bc84c3d559bfee193e3ac0b885e53701f4a5c7a787accb6ed7c9eb9eac8f75803cb319cc3f66e1c0215f0049d6b74
|
7
|
+
data.tar.gz: c6a12239202f9883c6c33f729286987095611cf6930b29548374f5aa0b2463f3fb996a4508e2e82cbbd18b59e156350275ae65d479cfab403f97e7e62e984733
|
@@ -482,6 +482,7 @@ module Cornucopia
|
|
482
482
|
instance_variable_set("@native_class", @found_element[:class])
|
483
483
|
|
484
484
|
if ::Capybara.current_session.driver.respond_to?(:browser) &&
|
485
|
+
::Capybara.current_session.driver.browser.respond_to?(:execute_script) &&
|
485
486
|
::Capybara.current_session.driver.browser.method(:execute_script).arity != 1
|
486
487
|
begin
|
487
488
|
# This is a "trick" that works with Selenium, but which might not work with other drivers...
|
@@ -9,6 +9,8 @@ if Object.const_defined?("Capybara") &&
|
|
9
9
|
class Document
|
10
10
|
alias_method :__cornucopia_orig_assert_selector, :assert_selector
|
11
11
|
alias_method :__cornucopia_orig_assert_no_selector, :assert_no_selector
|
12
|
+
alias_method :__cornucopia_orig_has_selector?, :has_selector?
|
13
|
+
alias_method :__cornucopia_orig_has_no_selector?, :has_no_selector?
|
12
14
|
|
13
15
|
include Cornucopia::Capybara::MatcherExtensions
|
14
16
|
end
|
@@ -25,6 +27,8 @@ if Object.const_defined?("Capybara") &&
|
|
25
27
|
class Element
|
26
28
|
alias_method :__cornucopia_orig_assert_selector, :assert_selector
|
27
29
|
alias_method :__cornucopia_orig_assert_no_selector, :assert_no_selector
|
30
|
+
alias_method :__cornucopia_orig_has_selector?, :has_selector?
|
31
|
+
alias_method :__cornucopia_orig_has_no_selector?, :has_no_selector?
|
28
32
|
|
29
33
|
include Cornucopia::Capybara::MatcherExtensions
|
30
34
|
end
|
@@ -12,11 +12,34 @@ module Cornucopia
|
|
12
12
|
__cornucopia_assert_selector_function(:assert_no_selector, *args)
|
13
13
|
end
|
14
14
|
|
15
|
+
def has_selector?(*args)
|
16
|
+
new_args = args.dup
|
17
|
+
options = (new_args.pop if new_args.length > 1 && new_args[-1].is_a?(Hash)) || {}
|
18
|
+
|
19
|
+
if Cornucopia::Util::Configuration.instance.ignore_has_selector_errors
|
20
|
+
options = { __cornucopia_no_analysis: true }.merge options
|
21
|
+
end
|
22
|
+
|
23
|
+
__cornucopia_assert_selector_function(:has_selector?, *new_args, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_no_selector?(*args)
|
27
|
+
new_args = args.dup
|
28
|
+
options = (new_args.pop if new_args.length > 1 && new_args[-1].is_a?(Hash)) || {}
|
29
|
+
|
30
|
+
if Cornucopia::Util::Configuration.instance.ignore_has_selector_errors
|
31
|
+
options = { __cornucopia_no_analysis: true }.merge options
|
32
|
+
end
|
33
|
+
__cornucopia_assert_selector_function(:has_no_selector?, *new_args, options)
|
34
|
+
end
|
35
|
+
|
15
36
|
def __cornucopia_assert_selector_function(assert_selector_function, *args)
|
16
37
|
retry_count = 0
|
17
38
|
result = nil
|
18
39
|
|
19
|
-
|
40
|
+
unless [:has_selector?, :has_no_selector?].include?(assert_selector_function)
|
41
|
+
support_options = __cornucopia__extract_selector_support_options(*args)
|
42
|
+
end
|
20
43
|
|
21
44
|
begin
|
22
45
|
retry_count += 1
|
@@ -18,14 +18,7 @@ Around do |scenario, block|
|
|
18
18
|
if scenario.failed?
|
19
19
|
seed_value = scenario.instance_variable_get(:@seed_value)
|
20
20
|
puts ("random seed for testing was: #{seed_value}")
|
21
|
-
end
|
22
|
-
|
23
|
-
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
24
|
-
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
25
|
-
end
|
26
21
|
|
27
|
-
After do |scenario|
|
28
|
-
if scenario.failed?
|
29
22
|
Cornucopia::Util::ReportBuilder.current_report.
|
30
23
|
within_section("Test Error: #{scenario.feature.title}:#{scenario.title}") do |report|
|
31
24
|
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
@@ -33,14 +26,12 @@ After do |scenario|
|
|
33
26
|
configured_report.add_report_objects scenario: scenario, cucumber: self
|
34
27
|
configured_report.generate_report(report)
|
35
28
|
end
|
36
|
-
|
37
|
-
|
38
|
-
# report_generator = Cornucopia::Configuration.report_configuration(:cucumber)
|
39
|
-
#
|
40
|
-
# report_generator.add_report_objects(self: self, scenario: scenario)
|
41
|
-
# report_generator.generate_report_for_object(report, diagnostics_name: scenario.file_colon_line)
|
42
|
-
# end
|
29
|
+
else
|
30
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
43
31
|
end
|
32
|
+
|
33
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
34
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
44
35
|
end
|
45
36
|
|
46
37
|
at_exit do
|
@@ -14,6 +14,13 @@ RSpec.configure do |config|
|
|
14
14
|
Cornucopia::Util::ReportBuilder.current_report.close
|
15
15
|
end
|
16
16
|
|
17
|
+
config.before(:all) do
|
18
|
+
@context_seed_value = Cornucopia::Util::Configuration.context_seed ||
|
19
|
+
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
20
|
+
|
21
|
+
srand(@context_seed_value)
|
22
|
+
end
|
23
|
+
|
17
24
|
config.around(:each) do |example|
|
18
25
|
@seed_value = Cornucopia::Util::Configuration.seed ||
|
19
26
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
@@ -30,7 +37,7 @@ RSpec.configure do |config|
|
|
30
37
|
example.run
|
31
38
|
|
32
39
|
if (test_example.exception)
|
33
|
-
puts ("random seed for testing was: #{@seed_value}")
|
40
|
+
puts ("random seed for testing was: #{@context_seed_value}, #{@seed_value}")
|
34
41
|
|
35
42
|
Cornucopia::Util::ReportBuilder.current_report.
|
36
43
|
within_section("Test Error: #{test_example.full_description}") do |report|
|
@@ -39,6 +46,8 @@ RSpec.configure do |config|
|
|
39
46
|
configured_report.add_report_objects example: test_example, rspec: RSpec
|
40
47
|
configured_report.generate_report(report)
|
41
48
|
end
|
49
|
+
else
|
50
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
@@ -5,13 +5,22 @@ function show_sub_report (event_obj)
|
|
5
5
|
if (!(event_obj.shiftKey || event_obj.ctrlKey || event_obj.metaKey || event_obj.altKey))
|
6
6
|
{
|
7
7
|
link_item = $ (event_obj.target);
|
8
|
-
$("#report-display-document").attr("src", link_item.attr ("href"))
|
9
|
-
event_obj.preventDefault();
|
8
|
+
$ ("#report-display-document").attr ("src", link_item.attr ("href"));
|
9
|
+
event_obj.preventDefault ();
|
10
10
|
}
|
11
11
|
}
|
12
12
|
|
13
|
+
function resize_list (event_obj)
|
14
|
+
{
|
15
|
+
var max_height = window.innerHeight - 15;
|
16
|
+
$ (".coruncopia-report-holder-list-holder").css ("max-height", max_height + "px");
|
17
|
+
$ ("#report-display-document").css ("max-height", max_height + "px");
|
18
|
+
}
|
19
|
+
|
13
20
|
$ (document).ready (function ()
|
14
21
|
{
|
15
22
|
$ (document).on ("click", "a.coruncopia-report-link", {}, show_sub_report);
|
23
|
+
$ (window).bind ("resize", {}, resize_list);
|
24
|
+
resize_list (null);
|
16
25
|
}
|
17
26
|
);
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<div class="coruncopia-report-holder-table">
|
7
7
|
<div class="coruncopia-report-holder-row">
|
8
8
|
<div class="coruncopia-report-holder-list-cell">
|
9
|
-
|
9
|
+
<div class="coruncopia-report-holder-list-holder">
|
10
10
|
<ul class="report-index-list">
|
11
11
|
%{report_list}
|
12
12
|
</ul>
|
13
|
-
|
13
|
+
</div>
|
14
14
|
</div>
|
15
15
|
<div class="coruncopia-report-body-cell">
|
16
16
|
<iframe class="coruncopia-report-body-frame" id="report-display-document" src=""></iframe>
|
@@ -8,22 +8,30 @@ Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
Spinach.hooks.
|
12
|
-
@
|
11
|
+
Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
12
|
+
@reported_error = false
|
13
|
+
@running_scenario = scenario_data
|
13
14
|
seed_value = Cornucopia::Util::Configuration.seed ||
|
14
15
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
15
16
|
|
16
|
-
|
17
|
+
scenario_data.instance_variable_set :@seed_value, seed_value
|
17
18
|
|
18
19
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
19
20
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
20
|
-
end
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
begin
|
23
|
+
block.call
|
24
|
+
ensure
|
25
|
+
@running_scenario = nil
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
28
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
29
|
+
|
30
|
+
unless @reported_error
|
31
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
32
|
+
end
|
33
|
+
@reported_error = false
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
37
|
Spinach.hooks.on_failed_step do |step_data, exception, location, step_definitions|
|
@@ -35,6 +43,8 @@ Spinach.hooks.on_error_step do |step_data, exception, location, step_definitions
|
|
35
43
|
end
|
36
44
|
|
37
45
|
def debug_failed_step(failure_description, step_data, exception, location, step_definitions)
|
46
|
+
@reported_error = true
|
47
|
+
|
38
48
|
seed_value = @running_scenario.instance_variable_get(:@seed_value)
|
39
49
|
puts ("random seed for testing was: #{seed_value}")
|
40
50
|
|
@@ -51,19 +61,6 @@ def debug_failed_step(failure_description, step_data, exception, location, step_
|
|
51
61
|
|
52
62
|
configured_report.generate_report(report)
|
53
63
|
end
|
54
|
-
|
55
|
-
# Cornucopia::Util::ReportBuilder.current_report.within_section("#{failure_description}:") do |report|
|
56
|
-
# report_generator = Cornucopia::Configuration.report_configuration(:spinach)
|
57
|
-
#
|
58
|
-
# report_generator.add_report_objects(failure_description: "#{failure_description} at:, #{location[0]}:#{location[1]}",
|
59
|
-
# step_data: step_data,
|
60
|
-
# exception: exception,
|
61
|
-
# location: location,
|
62
|
-
# step_definitions: step_definitions,
|
63
|
-
# running_scenario: @running_scenario
|
64
|
-
# )
|
65
|
-
# report_generator.generate_report_for_object(report, diagnostics_name: "#{step_data.name}:#{step_data.line}")
|
66
|
-
# end
|
67
64
|
end
|
68
65
|
|
69
66
|
Spinach.hooks.after_run do |status|
|
@@ -13,23 +13,26 @@ module Cornucopia
|
|
13
13
|
def initialize
|
14
14
|
@configurations = Cornucopia::Util::GenericSettings.new
|
15
15
|
|
16
|
-
configurations.order_seed
|
17
|
-
configurations.rand_seed
|
18
|
-
configurations.
|
19
|
-
configurations.
|
20
|
-
configurations.
|
21
|
-
configurations.
|
22
|
-
configurations.
|
23
|
-
configurations.
|
24
|
-
configurations.
|
25
|
-
configurations.
|
26
|
-
configurations.
|
27
|
-
configurations.
|
28
|
-
configurations.
|
16
|
+
configurations.order_seed = nil
|
17
|
+
configurations.rand_seed = nil
|
18
|
+
configurations.rand_context_seed = nil
|
19
|
+
configurations.user_log_files = {}
|
20
|
+
configurations.default_num_lines = 500
|
21
|
+
configurations.grab_logs = true
|
22
|
+
configurations.print_timeout_min = 10
|
23
|
+
configurations.selenium_cache_retry_count = 5
|
24
|
+
configurations.analyze_find_exceptions = true
|
25
|
+
configurations.analyze_selector_exceptions = true
|
26
|
+
configurations.ignore_finder_errors_on_success = true
|
27
|
+
configurations.ignore_has_selector_errors = true
|
28
|
+
configurations.retry_with_found = false
|
29
|
+
configurations.retry_match_with_found = false
|
30
|
+
configurations.open_report_settings = { default: false }
|
31
|
+
configurations.base_folder = "cornucopia_report"
|
29
32
|
|
30
33
|
# configurations.alternate_retry = false
|
31
34
|
|
32
|
-
configurations.default_configuration
|
35
|
+
configurations.default_configuration = {
|
33
36
|
rspec: {
|
34
37
|
min_fields: [
|
35
38
|
:example__full_description,
|
@@ -42,7 +45,14 @@ module Cornucopia
|
|
42
45
|
:example,
|
43
46
|
:example__example_group_instance,
|
44
47
|
:example__metadata__caller,
|
45
|
-
|
48
|
+
{
|
49
|
+
report_element: :rspec__configuration__seed,
|
50
|
+
report_options: { ignore_missing: true }
|
51
|
+
},
|
52
|
+
{
|
53
|
+
report_element: :rspec__configuration__ordering_manager__seed,
|
54
|
+
report_options: { ignore_missing: true }
|
55
|
+
},
|
46
56
|
:logs,
|
47
57
|
:capybara_page_diagnostics
|
48
58
|
],
|
@@ -60,7 +70,7 @@ module Cornucopia
|
|
60
70
|
:example__fixture_connections,
|
61
71
|
:example,
|
62
72
|
:example__example_group_instance,
|
63
|
-
]
|
73
|
+
],
|
64
74
|
},
|
65
75
|
cucumber: {
|
66
76
|
min_fields: [
|
@@ -280,12 +290,36 @@ module Cornucopia
|
|
280
290
|
Cornucopia::Util::Configuration.instance.configurations.rand_seed
|
281
291
|
end
|
282
292
|
|
293
|
+
# rand_context_seed is the seed value used to seed the srand function at the start of a context.
|
294
|
+
# This is done to allow tests with random elements in them to be repeatable.
|
295
|
+
# If a test fails, simply set Cornucopia::Util::Configuration.rand_context_seed to the
|
296
|
+
# value of the failed tests context_seed value (output in the stdout and the generated report)
|
297
|
+
# and run the test again. This should re-run the exact same test, resulting in a
|
298
|
+
# repeatable test even with randomization in it.
|
299
|
+
def context_seed=(value)
|
300
|
+
Cornucopia::Util::Configuration.instance.configurations.rand_context_seed = value
|
301
|
+
srand(value) if value
|
302
|
+
end
|
303
|
+
|
304
|
+
def context_seed
|
305
|
+
Cornucopia::Util::Configuration.instance.configurations.rand_context_seed
|
306
|
+
end
|
307
|
+
|
283
308
|
# order_seed is the seed value used to set the order that randomly ordered tests are run in.
|
284
309
|
# This is provided as a convenience method. I think it is easier to set this in rails_helper than it is to
|
285
310
|
# set it on the command line. This also provides a uniform method to do it.
|
286
311
|
def order_seed=(value)
|
287
312
|
Cornucopia::Util::Configuration.instance.configurations.order_seed = value
|
288
|
-
|
313
|
+
|
314
|
+
if value
|
315
|
+
if RSpec.configuration.respond_to?(:seed)
|
316
|
+
RSpec.configuration.seed = value
|
317
|
+
else
|
318
|
+
# :nocov:
|
319
|
+
RSpec.configuration.ordering_manager.seed = value
|
320
|
+
# :nocov:
|
321
|
+
end
|
322
|
+
end
|
289
323
|
end
|
290
324
|
|
291
325
|
def order_seed
|
@@ -458,6 +492,33 @@ module Cornucopia
|
|
458
492
|
Cornucopia::Util::Configuration.instance.configurations.analyze_selector_exceptions = value
|
459
493
|
end
|
460
494
|
|
495
|
+
# This setting is used by the report builder.
|
496
|
+
#
|
497
|
+
# If a test has finder errors but still succeeds, ignore the errors and do not report them. This is useful
|
498
|
+
# for tests that test the existence of an element on the page using something like:
|
499
|
+
# expect(my_page).not_to have_page_element
|
500
|
+
def ignore_finder_errors_on_success
|
501
|
+
Cornucopia::Util::Configuration.instance.configurations.ignore_finder_errors_on_success
|
502
|
+
end
|
503
|
+
|
504
|
+
def ignore_finder_errors_on_success=(value)
|
505
|
+
Cornucopia::Util::Configuration.instance.configurations.ignore_finder_errors_on_success = value
|
506
|
+
end
|
507
|
+
|
508
|
+
# This setting is used by the matcher analysis.
|
509
|
+
#
|
510
|
+
# Generally speaking has_selector? is allowed to return true or false without needing to be to analyzed.
|
511
|
+
# So, the system ignores has_selector? failures and doesn't output an analysis.
|
512
|
+
#
|
513
|
+
# This will perform an analysis for each has_selector? failure.
|
514
|
+
def ignore_has_selector_errors
|
515
|
+
Cornucopia::Util::Configuration.instance.configurations.ignore_has_selector_errors
|
516
|
+
end
|
517
|
+
|
518
|
+
def ignore_has_selector_errors=(value)
|
519
|
+
Cornucopia::Util::Configuration.instance.configurations.ignore_has_selector_errors = value
|
520
|
+
end
|
521
|
+
|
461
522
|
# Sometimes, the analysis process found the element when it wasn't found other ways.
|
462
523
|
# This will cause the finder to try again with the found element.
|
463
524
|
#
|
@@ -311,10 +311,12 @@ module Cornucopia
|
|
311
311
|
if instance_variable_name
|
312
312
|
report_object = parent_object.instance_variable_get(instance_variable_name)
|
313
313
|
else
|
314
|
-
|
315
|
-
|
314
|
+
unless report_options(export_field)[:ignore_missing]
|
315
|
+
report_object = nil
|
316
|
+
print_value = "Could not identify field: #{export_field[:report_element][0..level].join("__")} while exporting #{export_field[:report_element].join("__")}"
|
316
317
|
|
317
|
-
|
318
|
+
report_table.write_stats "ERROR", print_value
|
319
|
+
end
|
318
320
|
end
|
319
321
|
end
|
320
322
|
end
|
@@ -382,9 +384,7 @@ module Cornucopia
|
|
382
384
|
end
|
383
385
|
end
|
384
386
|
|
385
|
-
print_options = export_field
|
386
|
-
print_options ||= find_leaf_options(print_name).try(:[], :report_options)
|
387
|
-
print_options ||= {}
|
387
|
+
print_options = report_options(export_field)
|
388
388
|
|
389
389
|
if print_options[:label]
|
390
390
|
print_name = print_options[:label]
|
@@ -395,9 +395,29 @@ module Cornucopia
|
|
395
395
|
end
|
396
396
|
end
|
397
397
|
|
398
|
-
def
|
398
|
+
def report_options(export_field)
|
399
|
+
print_options = export_field[:report_options]
|
400
|
+
print_options ||= find_leaf_options(export_field).try(:[], :report_options)
|
401
|
+
print_options ||= {}
|
402
|
+
|
403
|
+
print_options
|
404
|
+
end
|
405
|
+
|
406
|
+
def find_leaf_options(export_field)
|
399
407
|
found_options = nil
|
400
408
|
|
409
|
+
if export_field[:report_element][-1] == :to_s
|
410
|
+
variable_name = export_field[:report_element][-2]
|
411
|
+
else
|
412
|
+
variable_name = export_field[:report_element][-1]
|
413
|
+
end
|
414
|
+
|
415
|
+
if export_field[:report_element].length >= 2
|
416
|
+
if variable_name.to_s =~ /^-?[0-9]+$/
|
417
|
+
variable_name = export_field[:report_element][-2]
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
401
421
|
if @leaf_options
|
402
422
|
@leaf_options.each do |leaf_option|
|
403
423
|
if leaf_option[:report_element].include?(variable_name)
|
@@ -447,7 +447,7 @@ module Cornucopia
|
|
447
447
|
end
|
448
448
|
|
449
449
|
def initialize_report_test_files
|
450
|
-
@report_body += test_list_item
|
450
|
+
@report_body += test_list_item.to_s
|
451
451
|
|
452
452
|
support_folder_name = report_test_folder_name
|
453
453
|
|
@@ -477,6 +477,24 @@ module Cornucopia
|
|
477
477
|
File.open(report_test_contents_page_name, "a:UTF-8", &block)
|
478
478
|
end
|
479
479
|
|
480
|
+
def test_succeeded
|
481
|
+
if @report_test_folder_name
|
482
|
+
FileUtils.rm_rf report_test_folder_name
|
483
|
+
@report_body.gsub!(@test_list_item, "")
|
484
|
+
|
485
|
+
if @report_body.blank?
|
486
|
+
FileUtils.rm_rf report_base_page_name
|
487
|
+
FileUtils.rm_rf File.join(report_folder_name, "report.js")
|
488
|
+
FileUtils.rm_rf File.join(report_folder_name, "cornucopia.css")
|
489
|
+
@report_body = "".html_safe
|
490
|
+
else
|
491
|
+
rebuild_report_holder_page
|
492
|
+
end
|
493
|
+
|
494
|
+
@test_number -= 1
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
480
498
|
def within_test(test_name, &block)
|
481
499
|
orig_test_name = @test_name
|
482
500
|
orig_test_folder = @report_test_folder_name
|
data/lib/cornucopia/version.rb
CHANGED
@@ -224,13 +224,13 @@ describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
|
224
224
|
|
225
225
|
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
226
226
|
|
227
|
-
retry_found
|
227
|
+
retry_found = [true, false].sample
|
228
228
|
# retry_alt = [true, false].sample
|
229
229
|
|
230
230
|
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
231
231
|
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
232
232
|
|
233
|
-
retry_found
|
233
|
+
retry_found = retry_found || nil
|
234
234
|
# retry_alt = retry_alt || nil
|
235
235
|
|
236
236
|
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return true
|
@@ -257,13 +257,13 @@ describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
|
257
257
|
|
258
258
|
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
259
259
|
|
260
|
-
retry_found
|
260
|
+
retry_found = [true, false].sample
|
261
261
|
# retry_alt = [true, false].sample
|
262
262
|
|
263
263
|
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
264
264
|
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
265
265
|
|
266
|
-
retry_found
|
266
|
+
retry_found = retry_found || nil
|
267
267
|
# retry_alt = retry_alt || nil
|
268
268
|
|
269
269
|
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return true
|
@@ -290,13 +290,13 @@ describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
|
290
290
|
|
291
291
|
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
292
292
|
|
293
|
-
retry_found
|
293
|
+
retry_found = [true, false].sample
|
294
294
|
# retry_alt = [true, false].sample
|
295
295
|
|
296
296
|
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
297
297
|
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
298
298
|
|
299
|
-
retry_found
|
299
|
+
retry_found = retry_found || nil
|
300
300
|
# retry_alt = retry_alt || nil
|
301
301
|
|
302
302
|
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return false
|
@@ -322,13 +322,13 @@ describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
|
322
322
|
|
323
323
|
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
324
324
|
|
325
|
-
retry_found
|
325
|
+
retry_found = [true, false].sample
|
326
326
|
# retry_alt = [true, false].sample
|
327
327
|
|
328
328
|
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
329
329
|
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
330
330
|
|
331
|
-
retry_found
|
331
|
+
retry_found = retry_found || nil
|
332
332
|
# retry_alt = retry_alt || nil
|
333
333
|
|
334
334
|
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return false
|
@@ -340,5 +340,36 @@ describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
|
340
340
|
end
|
341
341
|
end
|
342
342
|
end
|
343
|
+
|
344
|
+
context "with a sample test file" do
|
345
|
+
let(:base_folder) { File.absolute_path(File.join(File.dirname(@file_name_1), "../..")) }
|
346
|
+
|
347
|
+
before(:example) do
|
348
|
+
Cornucopia::Util::FileAsset.new("../../../spec/fixtures/sample_page.html").
|
349
|
+
create_file(File.join(base_folder, "sample_report/sample_file.html"))
|
350
|
+
|
351
|
+
::Capybara.current_session.visit("/sample_report/sample_file.html")
|
352
|
+
end
|
353
|
+
|
354
|
+
it "finds a has_selector? item and does not create a report" do
|
355
|
+
expect(::Capybara.current_session.has_selector?("\#select-box")).to be_truthy
|
356
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
357
|
+
end
|
358
|
+
|
359
|
+
it "does not find a has_selector? item and does not create a report" do
|
360
|
+
expect(::Capybara.current_session.has_selector?("\#select-box-not-there")).to be_falsey
|
361
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
362
|
+
end
|
363
|
+
|
364
|
+
it "finds a has_no_selector? item and does not create a report" do
|
365
|
+
expect(::Capybara.current_session.has_no_selector?("\#select-box-not-there")).to be_truthy
|
366
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
367
|
+
end
|
368
|
+
|
369
|
+
it "does not find a has_no_selector? item and does not create a report" do
|
370
|
+
expect(::Capybara.current_session.has_no_selector?("\#select-box")).to be_falsey
|
371
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
372
|
+
end
|
373
|
+
end
|
343
374
|
end
|
344
375
|
end
|
@@ -18,12 +18,29 @@ describe "Cornucopia::Util::Configuration" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
it "has a default context_seed value" do
|
22
|
+
expect(Cornucopia::Util::Configuration.context_seed).not_to be
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can set the context_seed value" do
|
26
|
+
begin
|
27
|
+
context_seed_value = rand(0..999999999999999999999999999)
|
28
|
+
|
29
|
+
Cornucopia::Util::Configuration.context_seed = context_seed_value
|
30
|
+
|
31
|
+
expect(Cornucopia::Util::Configuration.context_seed).to be == context_seed_value
|
32
|
+
ensure
|
33
|
+
Cornucopia::Util::Configuration.context_seed = nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
21
37
|
it "has a default order_seed value" do
|
22
38
|
expect(Cornucopia::Util::Configuration.order_seed).not_to be
|
23
39
|
end
|
24
40
|
|
25
41
|
it "can set the order_seed value" do
|
26
42
|
config_seed = RSpec.configuration.seed
|
43
|
+
|
27
44
|
begin
|
28
45
|
seed_value = rand(0..999999999999999999999999999)
|
29
46
|
|
@@ -37,6 +54,23 @@ describe "Cornucopia::Util::Configuration" do
|
|
37
54
|
end
|
38
55
|
end
|
39
56
|
|
57
|
+
it "can set the order_seed value on a newer version of RSpec" do
|
58
|
+
config_seed = RSpec.configuration.seed
|
59
|
+
|
60
|
+
begin
|
61
|
+
seed_value = rand(0..999999999999999999999999999)
|
62
|
+
|
63
|
+
expect(RSpec.configuration).to receive(:respond_to?).and_return false
|
64
|
+
Cornucopia::Util::Configuration.order_seed = seed_value
|
65
|
+
|
66
|
+
expect(Cornucopia::Util::Configuration.order_seed).to be == seed_value
|
67
|
+
expect(RSpec.configuration.seed).to be == seed_value
|
68
|
+
ensure
|
69
|
+
RSpec.configuration.seed = config_seed
|
70
|
+
Cornucopia::Util::Configuration.order_seed = nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
40
74
|
describe "log files" do
|
41
75
|
it "grabs logs by default" do
|
42
76
|
expect(Cornucopia::Util::Configuration.grab_logs).to be_truthy
|
@@ -286,6 +320,38 @@ describe "Cornucopia::Util::Configuration" do
|
|
286
320
|
end
|
287
321
|
end
|
288
322
|
|
323
|
+
describe "#ignore_finder_errors_on_success" do
|
324
|
+
it "#can read the default" do
|
325
|
+
expect(Cornucopia::Util::Configuration.ignore_finder_errors_on_success).to be_truthy
|
326
|
+
end
|
327
|
+
|
328
|
+
it "#can set the value" do
|
329
|
+
begin
|
330
|
+
Cornucopia::Util::Configuration.ignore_finder_errors_on_success = false
|
331
|
+
|
332
|
+
expect(Cornucopia::Util::Configuration.ignore_finder_errors_on_success).to be_falsy
|
333
|
+
ensure
|
334
|
+
Cornucopia::Util::Configuration.ignore_finder_errors_on_success = true
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
describe "#ignore_has_selector_errors" do
|
340
|
+
it "#can read the default" do
|
341
|
+
expect(Cornucopia::Util::Configuration.ignore_has_selector_errors).to be_truthy
|
342
|
+
end
|
343
|
+
|
344
|
+
it "#can set the value" do
|
345
|
+
begin
|
346
|
+
Cornucopia::Util::Configuration.ignore_has_selector_errors = false
|
347
|
+
|
348
|
+
expect(Cornucopia::Util::Configuration.ignore_has_selector_errors).to be_falsy
|
349
|
+
ensure
|
350
|
+
Cornucopia::Util::Configuration.ignore_has_selector_errors = true
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
289
355
|
describe "#retry_with_found" do
|
290
356
|
it "#can read the default" do
|
291
357
|
expect(Cornucopia::Util::Configuration.retry_with_found).to be_falsy
|
@@ -987,11 +987,53 @@ describe Cornucopia::Util::ConfiguredReport do
|
|
987
987
|
leaf_pos += leaf_size
|
988
988
|
end
|
989
989
|
|
990
|
-
rand_item = rand(0..
|
990
|
+
rand_item = rand(0..leaf_options.length - 1)
|
991
991
|
|
992
992
|
simple_report.leaf_options = leaf_options
|
993
|
-
expect(simple_report.find_leaf_options(
|
994
|
-
expect(simple_report.find_leaf_options(leaf_elements[leaf_pos])).not_to be
|
993
|
+
expect(simple_report.find_leaf_options(leaf_options[rand_item])).to be == leaf_options[rand_item]
|
994
|
+
expect(simple_report.find_leaf_options({ report_element: [leaf_elements[leaf_pos]] })).not_to be
|
995
|
+
end
|
996
|
+
|
997
|
+
it "ignores to_s" do
|
998
|
+
leaf_options = []
|
999
|
+
leaf_elements = rand(40..50).times.map { Faker::Lorem.word.to_sym }.uniq
|
1000
|
+
num_items = rand(5..10)
|
1001
|
+
leaf_pos = 0
|
1002
|
+
leaf_size = (leaf_elements.size - 1) / num_items
|
1003
|
+
|
1004
|
+
num_items.times do
|
1005
|
+
some_options = { some_option: Faker::Lorem.sentence }
|
1006
|
+
leaf_options << { report_element: [*leaf_elements[leaf_pos..leaf_pos + leaf_size - 1], :to_s],
|
1007
|
+
report_options: some_options }
|
1008
|
+
leaf_pos += leaf_size
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
rand_item = rand(0..leaf_options.length - 1)
|
1012
|
+
|
1013
|
+
simple_report.leaf_options = leaf_options
|
1014
|
+
expect(simple_report.find_leaf_options(leaf_options[rand_item])).to be == leaf_options[rand_item]
|
1015
|
+
expect(simple_report.find_leaf_options({ report_element: [leaf_elements[leaf_pos]] })).not_to be
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
it "ignores array indexes" do
|
1019
|
+
leaf_options = []
|
1020
|
+
leaf_elements = rand(40..50).times.map { Faker::Lorem.word.to_sym }.uniq
|
1021
|
+
num_items = rand(5..10)
|
1022
|
+
leaf_pos = 0
|
1023
|
+
leaf_size = (leaf_elements.size - 1) / num_items
|
1024
|
+
|
1025
|
+
num_items.times do
|
1026
|
+
some_options = { some_option: Faker::Lorem.sentence }
|
1027
|
+
leaf_options << { report_element: [*leaf_elements[leaf_pos..leaf_pos + leaf_size - 1], rand(0..1000).to_s.to_sym],
|
1028
|
+
report_options: some_options }
|
1029
|
+
leaf_pos += leaf_size
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
rand_item = rand(0..leaf_options.length - 1)
|
1033
|
+
|
1034
|
+
simple_report.leaf_options = leaf_options
|
1035
|
+
expect(simple_report.find_leaf_options(leaf_options[rand_item])).to be == leaf_options[rand_item]
|
1036
|
+
expect(simple_report.find_leaf_options({ report_element: [leaf_elements[leaf_pos]] })).not_to be
|
995
1037
|
end
|
996
1038
|
end
|
997
1039
|
|
@@ -941,6 +941,90 @@ describe Cornucopia::Util::ReportBuilder do
|
|
941
941
|
end
|
942
942
|
end
|
943
943
|
|
944
|
+
describe "#test_succeeded" do
|
945
|
+
it "deletes a sub-test as if nothing failed if it is the only one." do
|
946
|
+
current_report = send(report_settings[:report])
|
947
|
+
|
948
|
+
test_folder = nil
|
949
|
+
test_file = nil
|
950
|
+
|
951
|
+
rand(1..3).times do
|
952
|
+
current_report.within_test(test_names[0]) do
|
953
|
+
current_report.within_section(section_names[0]) do |report_section|
|
954
|
+
report_section.within_table do |report_table|
|
955
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
956
|
+
end
|
957
|
+
end
|
958
|
+
|
959
|
+
test_folder = current_report.report_test_folder_name
|
960
|
+
test_file = current_report.report_base_page_name
|
961
|
+
|
962
|
+
expect(File.exists?(test_file)).to be_truthy
|
963
|
+
expect(File.directory?(test_folder)).to be_truthy
|
964
|
+
|
965
|
+
current_report.test_succeeded
|
966
|
+
|
967
|
+
expect(File.exists?(test_file)).to be_falsey
|
968
|
+
expect(File.directory?(test_folder)).to be_falsey
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
current_report.close
|
973
|
+
|
974
|
+
expect(File.exists?(test_file)).to be_truthy
|
975
|
+
expect(File.directory?(test_folder)).to be_falsey
|
976
|
+
|
977
|
+
read_file = File.read(current_report.report_contents_page_name)
|
978
|
+
expect(read_file).not_to match /#{test_names[0]}/
|
979
|
+
expect(read_file).to match /No Errors to report/
|
980
|
+
end
|
981
|
+
|
982
|
+
it "deletes a sub-test as if it doesn't exist" do
|
983
|
+
current_report = send(report_settings[:report])
|
984
|
+
|
985
|
+
current_report.within_test(test_names[0]) do
|
986
|
+
current_report.within_section(section_names[0]) do |report_section|
|
987
|
+
report_section.within_table do |report_table|
|
988
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
989
|
+
end
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
test_folder = nil
|
994
|
+
test_file = nil
|
995
|
+
|
996
|
+
rand(1..3).times do
|
997
|
+
current_report.within_test(test_names[1]) do
|
998
|
+
current_report.within_section(section_names[1]) do |report_section|
|
999
|
+
report_section.within_table do |report_table|
|
1000
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
test_folder = current_report.report_test_folder_name
|
1005
|
+
test_file = current_report.report_base_page_name
|
1006
|
+
|
1007
|
+
expect(File.exists?(test_file)).to be_truthy
|
1008
|
+
expect(File.directory?(test_folder)).to be_truthy
|
1009
|
+
|
1010
|
+
current_report.test_succeeded
|
1011
|
+
|
1012
|
+
expect(File.exists?(test_file)).to be_truthy
|
1013
|
+
expect(File.directory?(test_folder)).to be_falsey
|
1014
|
+
end
|
1015
|
+
end
|
1016
|
+
|
1017
|
+
current_report.close
|
1018
|
+
|
1019
|
+
expect(File.exists?(test_file)).to be_truthy
|
1020
|
+
expect(File.directory?(test_folder)).to be_falsey
|
1021
|
+
|
1022
|
+
read_file = File.read(current_report.report_base_page_name)
|
1023
|
+
expect(read_file).to match /#{test_names[0]}/
|
1024
|
+
expect(read_file).not_to match /#{test_names[1]}/
|
1025
|
+
end
|
1026
|
+
end
|
1027
|
+
|
944
1028
|
describe "#within_test" do
|
945
1029
|
it "starts a test with a specific name" do
|
946
1030
|
current_report = send(report_settings[:report])
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|