cornucopia 0.1.29 → 0.1.30
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/README.md +16 -0
- data/lib/cornucopia.rb +1 -0
- data/lib/cornucopia/capybara/finder_diagnostics.rb +22 -8
- data/lib/cornucopia/cucumber_hooks.rb +17 -38
- data/lib/cornucopia/rspec_hooks.rb +8 -4
- data/lib/cornucopia/spinach_hooks.rb +26 -25
- data/lib/cornucopia/util/configuration.rb +47 -18
- data/lib/cornucopia/util/test_helper.rb +51 -0
- data/lib/cornucopia/version.rb +1 -1
- data/spec/fixtures/sample_page.html +2 -2
- data/spec/lib/capybara/finder_diagnostics_spec.rb +38 -8
- data/spec/lib/util/configuration_spec.rb +38 -0
- data/spec/lib/util/test_helper_spec.rb +166 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1a6bac03caafb4e19e69fd39ae9b1cae0b1f986
|
4
|
+
data.tar.gz: a3fea23935ebb26c03735bf3decc99fb78c3041b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d4902517687e1cb43d80da0ab8438fea4771b1472f2d5c1e1099fde45ba7da473f58f996d9c17638131114964f6a8869d47f9f303293c1360aaf38aabcdbb69
|
7
|
+
data.tar.gz: fd5da08ffc48b432f845c717b6d5cc69896332c87c9bc2ec08c6c2c1c6c71b68d9d3223021969988de6904d6ddf2aaa400ebf2ae6b009b0470a55b0ac8719558
|
data/README.md
CHANGED
@@ -375,6 +375,22 @@ The configuration class contains the various configurations that are used by the
|
|
375
375
|
you do not specify a type of report the value you specify will be the default value used for any report that is
|
376
376
|
generated.
|
377
377
|
|
378
|
+
* **record_test_start_and_end_in_log**
|
379
|
+
|
380
|
+
When true, this causes Cornucopia to output a line in the log file indicating the start and end of a test.
|
381
|
+
|
382
|
+
The default value is true.
|
383
|
+
|
384
|
+
* **record_test_start_and_end_format**
|
385
|
+
|
386
|
+
This parameter specifies the format of the message that is recorded in the log file. You can use the following
|
387
|
+
variables in the format string to get the appropriate values:
|
388
|
+
|
389
|
+
* `%{start_end}` - This will be the words "Start" or "End"
|
390
|
+
* `%{test_name}` - This will be the name of the test.
|
391
|
+
|
392
|
+
The default value is "******** %{start_end}: %{test_name}".
|
393
|
+
|
378
394
|
* And more...
|
379
395
|
|
380
396
|
There are more configurations. They are commented in the configuraiton.rb file. If I didn't include them here,
|
data/lib/cornucopia.rb
CHANGED
@@ -7,6 +7,7 @@ require "cornucopia/util/log_capture"
|
|
7
7
|
require "cornucopia/util/pretty_formatter"
|
8
8
|
require "cornucopia/util/report_table"
|
9
9
|
require "cornucopia/util/report_builder"
|
10
|
+
require "cornucopia/util/test_helper"
|
10
11
|
require "cornucopia/capybara/finder_diagnostics"
|
11
12
|
require "cornucopia/capybara/page_diagnostics"
|
12
13
|
require "cornucopia/capybara/finder_extensions"
|
@@ -335,9 +335,16 @@ module Cornucopia
|
|
335
335
|
from_element = @test_object
|
336
336
|
end
|
337
337
|
|
338
|
-
|
339
|
-
|
340
|
-
|
338
|
+
begin
|
339
|
+
@all_elements = from_element.all(*search_args, visible: false, __cornucopia_no_analysis: true).to_a
|
340
|
+
rescue
|
341
|
+
@all_elements = []
|
342
|
+
end
|
343
|
+
|
344
|
+
if @all_elements
|
345
|
+
@all_elements = @all_elements.map do |element|
|
346
|
+
FoundElement.new(element)
|
347
|
+
end.compact
|
341
348
|
end
|
342
349
|
end
|
343
350
|
|
@@ -348,13 +355,20 @@ module Cornucopia
|
|
348
355
|
unless @all_other_elements
|
349
356
|
from_element = ::Capybara::current_session
|
350
357
|
|
351
|
-
|
352
|
-
|
353
|
-
|
358
|
+
begin
|
359
|
+
@all_other_elements = from_element.all(*search_args, visible: false, __cornucopia_no_analysis: true).to_a
|
360
|
+
rescue
|
361
|
+
@all_other_elements = []
|
354
362
|
end
|
355
363
|
|
356
|
-
|
357
|
-
|
364
|
+
if @all_other_elements
|
365
|
+
@all_other_elements = @all_other_elements.map do |element|
|
366
|
+
FoundElement.new(element) unless all_elements.include?(element)
|
367
|
+
end
|
368
|
+
|
369
|
+
@all_other_elements = @all_other_elements - @all_elements
|
370
|
+
@all_other_elements.compact!
|
371
|
+
end
|
358
372
|
end
|
359
373
|
|
360
374
|
@all_other_elements
|
@@ -5,18 +5,16 @@ load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname
|
|
5
5
|
if Cucumber::VERSION.split[0].to_i >= 2
|
6
6
|
After do |scenario, block|
|
7
7
|
if scenario.failed?
|
8
|
-
report_name = "Page Dump for:
|
9
|
-
if scenario.respond_to?(:feature)
|
10
|
-
report_name = "Page Dump for: #{scenario.feature.title}:#{scenario.title}"
|
11
|
-
else
|
12
|
-
report_name = "Page Dump for: Line - #{scenario.line}"
|
13
|
-
end
|
8
|
+
report_name = "Page Dump for: #{Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)}"
|
14
9
|
|
15
10
|
Cornucopia::Capybara::PageDiagnostics.dump_details(section_label: report_name)
|
16
11
|
end
|
17
12
|
end
|
18
13
|
|
19
14
|
Around do |scenario, block|
|
15
|
+
test_name = Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)
|
16
|
+
Cornucopia::Util::TestHelper.instance.record_test_start(test_name)
|
17
|
+
|
20
18
|
seed_value = Cornucopia::Util::Configuration.seed ||
|
21
19
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
22
20
|
|
@@ -25,15 +23,7 @@ if Cucumber::VERSION.split[0].to_i >= 2
|
|
25
23
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
26
24
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
27
25
|
|
28
|
-
|
29
|
-
if scenario.respond_to?(:feature)
|
30
|
-
test_name = "#{scenario.feature.title} : #{scenario.title}"
|
31
|
-
elsif scenario.respond_to?(:line)
|
32
|
-
test_name = "Scenario - Line: #{scenario.line}"
|
33
|
-
else
|
34
|
-
test_name = "Scenario - Unknown"
|
35
|
-
end
|
36
|
-
Cornucopia::Util::ReportBuilder.current_report.within_test(test_name) do
|
26
|
+
Cornucopia::Util::ReportBuilder.current_report.within_test("Scenario - #{test_name}") do
|
37
27
|
block.call
|
38
28
|
end
|
39
29
|
|
@@ -41,13 +31,7 @@ if Cucumber::VERSION.split[0].to_i >= 2
|
|
41
31
|
seed_value = scenario.instance_variable_get(:@seed_value)
|
42
32
|
puts ("random seed for testing was: #{seed_value}")
|
43
33
|
|
44
|
-
|
45
|
-
if scenario.respond_to?(:feature)
|
46
|
-
report_name = "Test Error: #{scenario.feature.title}:#{scenario.title}"
|
47
|
-
else
|
48
|
-
report_name = "Line - #{scenario.line}"
|
49
|
-
end
|
50
|
-
Cornucopia::Util::ReportBuilder.current_report.within_section(report_name) do |report|
|
34
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section("Test Error: #{test_name}") do |report|
|
51
35
|
configured_report = nil
|
52
36
|
if scenario.respond_to?(:feature)
|
53
37
|
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
@@ -64,9 +48,14 @@ if Cucumber::VERSION.split[0].to_i >= 2
|
|
64
48
|
|
65
49
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
66
50
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
51
|
+
|
52
|
+
Cornucopia::Util::TestHelper.instance.record_test_end(test_name)
|
67
53
|
end
|
68
54
|
else
|
69
55
|
Before do |scenario, block|
|
56
|
+
test_name = Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)
|
57
|
+
Cornucopia::Util::TestHelper.instance.record_test_start(test_name)
|
58
|
+
|
70
59
|
seed_value = Cornucopia::Util::Configuration.seed ||
|
71
60
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
72
61
|
|
@@ -75,29 +64,17 @@ else
|
|
75
64
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
76
65
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
77
66
|
|
78
|
-
|
79
|
-
if scenario.respond_to?(:feature)
|
80
|
-
test_name = "#{scenario.feature.title} : #{scenario.title}"
|
81
|
-
elsif scenario.respond_to?(:line)
|
82
|
-
test_name = "Scenario - Line: #{scenario.line}"
|
83
|
-
else
|
84
|
-
test_name = "Scenario - Unknown"
|
85
|
-
end
|
86
|
-
Cornucopia::Util::ReportBuilder.current_report.start_test(scenario, test_name)
|
67
|
+
Cornucopia::Util::ReportBuilder.current_report.start_test(scenario, "Scenario - #{test_name}")
|
87
68
|
end
|
88
69
|
|
89
70
|
After do |scenario, block|
|
71
|
+
test_name = Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)
|
72
|
+
|
90
73
|
if scenario.failed?
|
91
74
|
seed_value = scenario.instance_variable_get(:@seed_value)
|
92
75
|
puts ("random seed for testing was: #{seed_value}")
|
93
76
|
|
94
|
-
|
95
|
-
if scenario.respond_to?(:feature)
|
96
|
-
report_name = "Test Error: #{scenario.feature.title}:#{scenario.title}"
|
97
|
-
else
|
98
|
-
report_name = "Line - #{scenario.line}"
|
99
|
-
end
|
100
|
-
Cornucopia::Util::ReportBuilder.current_report.within_section(report_name) do |report|
|
77
|
+
Cornucopia::Util::ReportBuilder.current_report.within_section("Test Error: #{test_name}") do |report|
|
101
78
|
configured_report = nil
|
102
79
|
if scenario.respond_to?(:feature)
|
103
80
|
configured_report = Cornucopia::Util::Configuration.report_configuration :cucumber
|
@@ -116,6 +93,8 @@ else
|
|
116
93
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
117
94
|
|
118
95
|
Cornucopia::Util::ReportBuilder.current_report.end_test(scenario)
|
96
|
+
|
97
|
+
Cornucopia::Util::TestHelper.instance.record_test_end(test_name)
|
119
98
|
end
|
120
99
|
end
|
121
100
|
|
@@ -34,6 +34,12 @@ RSpec.configure do |config|
|
|
34
34
|
end
|
35
35
|
|
36
36
|
config.around(:each) do |example|
|
37
|
+
test_example = example.example if example.respond_to?(:example)
|
38
|
+
test_example ||= self.example if self.respond_to?(:example)
|
39
|
+
test_example ||= example
|
40
|
+
|
41
|
+
Cornucopia::Util::TestHelper.instance.record_test_start(test_example.full_description)
|
42
|
+
|
37
43
|
@seed_value = Cornucopia::Util::Configuration.seed ||
|
38
44
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
39
45
|
|
@@ -42,10 +48,6 @@ RSpec.configure do |config|
|
|
42
48
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
43
49
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
44
50
|
|
45
|
-
test_example = example.example if example.respond_to?(:example)
|
46
|
-
test_example ||= self.example if self.respond_to?(:example)
|
47
|
-
test_example ||= example
|
48
|
-
|
49
51
|
Cornucopia::Util::ReportBuilder.current_report.within_test(test_example.full_description) do
|
50
52
|
example.run
|
51
53
|
|
@@ -66,5 +68,7 @@ RSpec.configure do |config|
|
|
66
68
|
|
67
69
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
68
70
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
71
|
+
|
72
|
+
Cornucopia::Util::TestHelper.instance.record_test_end(test_example.full_description)
|
69
73
|
end
|
70
74
|
end
|
@@ -3,35 +3,36 @@ load ::File.expand_path("capybara/install_finder_extensions.rb", File.dirname(__
|
|
3
3
|
load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
|
4
4
|
|
5
5
|
Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
6
|
-
Cornucopia::Util::
|
7
|
-
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
|
12
|
-
@reported_error = false
|
13
|
-
@running_scenario = scenario_data
|
14
|
-
seed_value = Cornucopia::Util::Configuration.seed ||
|
15
|
-
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
6
|
+
test_name = Cornucopia::Util::TestHelper.spinach_name(scenario_data)
|
7
|
+
Cornucopia::Util::TestHelper.instance.record_test_start(test_name)
|
16
8
|
|
17
|
-
|
9
|
+
Cornucopia::Util::ReportBuilder.current_report.within_test(test_name) do
|
10
|
+
Cornucopia::Util::TestHelper.instance.spinach_reported_error = false
|
11
|
+
Cornucopia::Util::TestHelper.instance.spinach_running_scenario = scenario_data
|
12
|
+
seed_value = Cornucopia::Util::Configuration.seed ||
|
13
|
+
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
18
14
|
|
19
|
-
|
20
|
-
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
21
|
-
|
22
|
-
begin
|
23
|
-
block.call
|
24
|
-
ensure
|
25
|
-
@running_scenario = nil
|
15
|
+
scenario_data.instance_variable_set :@seed_value, seed_value
|
26
16
|
|
27
17
|
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
28
18
|
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
29
19
|
|
30
|
-
|
31
|
-
|
20
|
+
begin
|
21
|
+
block.call
|
22
|
+
ensure
|
23
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.clear_diagnosed_finders
|
24
|
+
Cornucopia::Capybara::PageDiagnostics.clear_dumped_pages
|
25
|
+
|
26
|
+
unless Cornucopia::Util::TestHelper.instance.spinach_reported_error
|
27
|
+
Cornucopia::Util::ReportBuilder.current_report.test_succeeded
|
28
|
+
end
|
29
|
+
|
30
|
+
Cornucopia::Util::TestHelper.instance.spinach_running_scenario = nil
|
31
|
+
Cornucopia::Util::TestHelper.instance.spinach_reported_error = false
|
32
32
|
end
|
33
|
-
@reported_error = false
|
34
33
|
end
|
34
|
+
|
35
|
+
Cornucopia::Util::TestHelper.instance.record_test_end(test_name)
|
35
36
|
end
|
36
37
|
|
37
38
|
Spinach.hooks.on_failed_step do |step_data, exception, location, step_definitions|
|
@@ -43,17 +44,17 @@ Spinach.hooks.on_error_step do |step_data, exception, location, step_definitions
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def debug_failed_step(failure_description, step_data, exception, location, step_definitions)
|
46
|
-
|
47
|
+
Cornucopia::Util::TestHelper.instance.spinach_reported_error = true
|
47
48
|
|
48
|
-
seed_value =
|
49
|
+
seed_value = Cornucopia::Util::TestHelper.instance.spinach_running_scenario.instance_variable_get(:@seed_value)
|
49
50
|
puts ("random seed for testing was: #{seed_value}")
|
50
51
|
|
51
52
|
Cornucopia::Util::ReportBuilder.current_report.
|
52
|
-
within_section("Test Error: #{
|
53
|
+
within_section("Test Error: #{Cornucopia::Util::TestHelper.instance.spinach_running_scenario.feature.name}") do |report|
|
53
54
|
configured_report = Cornucopia::Util::Configuration.report_configuration :spinach
|
54
55
|
|
55
56
|
configured_report.add_report_objects failure_description: "#{failure_description} at:, #{location[0]}:#{location[1]}",
|
56
|
-
running_scenario:
|
57
|
+
running_scenario: Cornucopia::Util::TestHelper.instance.spinach_running_scenario,
|
57
58
|
step_data: step_data,
|
58
59
|
exception: exception,
|
59
60
|
location: location,
|
@@ -13,27 +13,29 @@ 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.rand_context_seed
|
19
|
-
configurations.user_log_files
|
20
|
-
configurations.default_num_lines
|
21
|
-
configurations.grab_logs
|
22
|
-
configurations.backup_logs_on_failure
|
23
|
-
configurations.print_timeout_min
|
24
|
-
configurations.selenium_cache_retry_count
|
25
|
-
configurations.analyze_find_exceptions
|
26
|
-
configurations.analyze_selector_exceptions
|
27
|
-
configurations.ignore_finder_errors_on_success
|
28
|
-
configurations.ignore_has_selector_errors
|
29
|
-
configurations.
|
30
|
-
configurations.
|
31
|
-
configurations.
|
32
|
-
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.backup_logs_on_failure = true
|
23
|
+
configurations.print_timeout_min = 10
|
24
|
+
configurations.selenium_cache_retry_count = 5
|
25
|
+
configurations.analyze_find_exceptions = true
|
26
|
+
configurations.analyze_selector_exceptions = true
|
27
|
+
configurations.ignore_finder_errors_on_success = true
|
28
|
+
configurations.ignore_has_selector_errors = true
|
29
|
+
configurations.record_test_start_and_end_in_log = true
|
30
|
+
configurations.record_test_start_and_end_format = "******** %{start_end}: %{test_name}"
|
31
|
+
configurations.retry_with_found = false
|
32
|
+
configurations.retry_match_with_found = false
|
33
|
+
configurations.open_report_settings = { default: false }
|
34
|
+
configurations.base_folder = "cornucopia_report"
|
33
35
|
|
34
36
|
# configurations.alternate_retry = false
|
35
37
|
|
36
|
-
configurations.default_configuration
|
38
|
+
configurations.default_configuration = {
|
37
39
|
rspec: {
|
38
40
|
min_fields: [
|
39
41
|
:example__full_description,
|
@@ -681,6 +683,33 @@ module Cornucopia
|
|
681
683
|
def base_folder=(value)
|
682
684
|
Cornucopia::Util::Configuration.instance.configurations.base_folder = value
|
683
685
|
end
|
686
|
+
|
687
|
+
# This setting is used by the test system hooks.
|
688
|
+
#
|
689
|
+
# If true (the default) this will cause the system to output a line to the Rails log indicating when a test
|
690
|
+
# starts and when it ends.
|
691
|
+
def record_test_start_and_end_in_log
|
692
|
+
Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_in_log
|
693
|
+
end
|
694
|
+
|
695
|
+
def record_test_start_and_end_in_log=(value)
|
696
|
+
Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_in_log = value
|
697
|
+
end
|
698
|
+
|
699
|
+
# This setting is used by the test system hooks.
|
700
|
+
#
|
701
|
+
# This value specifies the text that is output into the log file at the start/end of a test.
|
702
|
+
# Two variables are passed into the format string to be inserted into the text:
|
703
|
+
#
|
704
|
+
# * %{start_end} - This will be either "Start" or "End"
|
705
|
+
# * %{test_name} - This will the the name of the test.
|
706
|
+
def record_test_start_and_end_format
|
707
|
+
Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_format
|
708
|
+
end
|
709
|
+
|
710
|
+
def record_test_start_and_end_format=(value)
|
711
|
+
Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_format = value
|
712
|
+
end
|
684
713
|
end
|
685
714
|
end
|
686
715
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "singleton"
|
2
|
+
|
3
|
+
module Cornucopia
|
4
|
+
module Util
|
5
|
+
class TestHelper
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
attr_accessor :spinach_reported_error, :spinach_running_scenario
|
9
|
+
|
10
|
+
def cucumber_name(scenario)
|
11
|
+
report_name = "Unknown"
|
12
|
+
if scenario.respond_to?(:feature)
|
13
|
+
report_name = "#{scenario.feature.title}:#{scenario.title}"
|
14
|
+
elsif scenario.respond_to?(:line)
|
15
|
+
report_name = "Line - #{scenario.line}"
|
16
|
+
end
|
17
|
+
|
18
|
+
report_name
|
19
|
+
end
|
20
|
+
|
21
|
+
def spinach_name(scenario_data)
|
22
|
+
"#{scenario_data.feature.name} : #{scenario_data.name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def rspec_name(example)
|
26
|
+
example.full_description
|
27
|
+
end
|
28
|
+
|
29
|
+
def record_test_start(test_name)
|
30
|
+
record_test("Start", test_name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def record_test_end(test_name)
|
34
|
+
record_test("End", test_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_message(start_end, test_name)
|
38
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_format % {
|
39
|
+
start_end: start_end,
|
40
|
+
test_name: test_name
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def record_test(start_end, test_name)
|
45
|
+
if Cornucopia::Util::Configuration.record_test_start_and_end_in_log
|
46
|
+
Rails.logger.error(test_message(start_end, test_name))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/cornucopia/version.rb
CHANGED
@@ -79,7 +79,7 @@
|
|
79
79
|
</div>
|
80
80
|
|
81
81
|
<a class="a-class b-class c-class" id="hidden-cool-link" href="#" onclick="alert('cool!');">Cool alert!</a>
|
82
|
-
<input class="a-class b-class c-class" id="hidden-cool-button" type="button" value="Still cool!" onclick="alert('still cool!');" />
|
82
|
+
<input class="a-class b-class c-class" id="hidden-cool-button" type="button" value="Still cool!" aria-meta-data='This is some meta-data; function("call");' onclick="alert('still cool!');" />
|
83
83
|
<label>text box</label><input id="hidden-text-box" type="text" />
|
84
84
|
|
85
85
|
<div class="radio-container">
|
@@ -118,7 +118,7 @@
|
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<a id="cool-link" href="#" onclick="alert('cool!');">Cool alert!</a>
|
121
|
-
<input id="cool-button" type="button" value="Still cool!" onclick="alert('still cool!');" />
|
121
|
+
<input id="cool-button" type="button" value="Still cool!" onclick="alert('still cool!');" aria-meta-data='This is some meta-data; function("call");' />
|
122
122
|
<label>text box</label><input id="text-box" type="text" />
|
123
123
|
|
124
124
|
<div class="radio-container">
|
@@ -307,6 +307,36 @@ describe Cornucopia::Capybara::FinderDiagnostics, type: :feature do
|
|
307
307
|
::Capybara.current_session.visit("/sample_report/sample_file.html")
|
308
308
|
end
|
309
309
|
|
310
|
+
it "creates a report even with an invalid finder" do
|
311
|
+
expect { ::Capybara.current_session.find(:css, "a:invalid('finder')") }.
|
312
|
+
to raise_exception(Selenium::WebDriver::Error::InvalidSelectorError)
|
313
|
+
|
314
|
+
report_page = CornucopiaReportApp.cornucopia_report_holder_page
|
315
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
316
|
+
|
317
|
+
expect(report_page.tests.length).to be >= 1
|
318
|
+
report_page.tests[0].click
|
319
|
+
report_page.displayed_test do |test_page|
|
320
|
+
test_page.contents do |contents_frame|
|
321
|
+
expect(contents_frame.errors.length).to be == 1
|
322
|
+
contents_frame.errors[0].more_details.show_hide.click
|
323
|
+
expect(contents_frame.errors[0].more_details.details.rows.length).to eq 13
|
324
|
+
expect(contents_frame.errors[0].more_details.details.row(0).labels[0].text).to eq "name"
|
325
|
+
expect(contents_frame.errors[0].more_details.details.row(1).labels[0].text).to eq "args"
|
326
|
+
expect(contents_frame.errors[0].more_details.details.row(2).labels[0].text).to eq "guessed_types"
|
327
|
+
expect(contents_frame.errors[0].more_details.details.row(3).labels[0].text).to eq "support_options"
|
328
|
+
expect(contents_frame.errors[0].more_details.details.row(4).labels[0].text).to eq "page_url"
|
329
|
+
expect(contents_frame.errors[0].more_details.details.row(5).labels[0].text).to eq "title"
|
330
|
+
expect(contents_frame.errors[0].more_details.details.row(6).labels[0].text).to eq "screen_shot"
|
331
|
+
expect(contents_frame.errors[0].more_details.details.row(7).labels[0].text).to eq "html_file"
|
332
|
+
expect(contents_frame.errors[0].more_details.details.row(8).labels[0].text).to eq "html_frame"
|
333
|
+
expect(contents_frame.errors[0].more_details.details.row(9).labels[0].text).to eq "html_source"
|
334
|
+
expect(contents_frame.errors[0].more_details.details.row(10).labels[0].text).to eq "page_height"
|
335
|
+
expect(contents_frame.errors[0].more_details.details.row(11).labels[0].text).to eq "page_width"
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
310
340
|
it "finds hidden elements during analysis" do
|
311
341
|
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
312
342
|
expect { base_object.find("input[type=button]") }.to raise_error(Capybara::ElementNotFound)
|
@@ -335,13 +365,14 @@ describe Cornucopia::Capybara::FinderDiagnostics, type: :feature do
|
|
335
365
|
expect(hidden_row_specs[8].labels[0].text).to be == "elem_value"
|
336
366
|
expect(hidden_row_specs[9].labels[0].text).to be == "elem_visible"
|
337
367
|
expect(hidden_row_specs[9].values[0].text).to be == "false"
|
338
|
-
expect(hidden_row_specs[10].labels[0].text).to be == "
|
339
|
-
expect(hidden_row_specs[11].labels[0].text).to be == "
|
340
|
-
expect(hidden_row_specs[12].labels[0].text).to be == "
|
341
|
-
expect(hidden_row_specs[13].labels[0].text).to be == "
|
342
|
-
expect(hidden_row_specs[14].labels[0].text).to be == "
|
343
|
-
expect(hidden_row_specs[15].labels[0].text).to be == "
|
344
|
-
expect(hidden_row_specs[
|
368
|
+
expect(hidden_row_specs[10].labels[0].text).to be == "native_aria_meta_data"
|
369
|
+
expect(hidden_row_specs[11].labels[0].text).to be == "native_class"
|
370
|
+
expect(hidden_row_specs[12].labels[0].text).to be == "native_onclick"
|
371
|
+
expect(hidden_row_specs[13].labels[0].text).to be == "native_size"
|
372
|
+
expect(hidden_row_specs[14].labels[0].text).to be == "width"
|
373
|
+
expect(hidden_row_specs[15].labels[0].text).to be == "height"
|
374
|
+
expect(hidden_row_specs[16].labels[0].text).to be == "native_type"
|
375
|
+
expect(hidden_row_specs[16].values[0].text).to be == "button"
|
345
376
|
end
|
346
377
|
end
|
347
378
|
end
|
@@ -551,7 +582,6 @@ describe Cornucopia::Capybara::FinderDiagnostics, type: :feature do
|
|
551
582
|
end
|
552
583
|
|
553
584
|
it "works with assert_no_selector" do
|
554
|
-
# 621023375412314903581404663773388410917
|
555
585
|
begin
|
556
586
|
Cornucopia::Util::Configuration.retry_match_with_found = true
|
557
587
|
|
@@ -457,6 +457,44 @@ describe "Cornucopia::Util::Configuration" do
|
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
460
|
+
describe "#record_test_start_and_end_in_log" do
|
461
|
+
it "has a default value" do
|
462
|
+
expect(Cornucopia::Util::Configuration.record_test_start_and_end_in_log).to be_truthy
|
463
|
+
end
|
464
|
+
|
465
|
+
it "can set the value" do
|
466
|
+
begin
|
467
|
+
new_value = false
|
468
|
+
|
469
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_in_log = new_value
|
470
|
+
|
471
|
+
expect(Cornucopia::Util::Configuration.record_test_start_and_end_in_log).to be_falsey
|
472
|
+
ensure
|
473
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_in_log = true
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
|
478
|
+
describe "#record_test_start_and_end_format" do
|
479
|
+
it "has a default value" do
|
480
|
+
expect(Cornucopia::Util::Configuration.record_test_start_and_end_format).to eq "******** %{start_end}: %{test_name}"
|
481
|
+
end
|
482
|
+
|
483
|
+
it "can set the value" do
|
484
|
+
orig_value = Cornucopia::Util::Configuration.record_test_start_and_end_format
|
485
|
+
|
486
|
+
begin
|
487
|
+
new_value = Faker::Lorem.sentence
|
488
|
+
|
489
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_format = new_value
|
490
|
+
|
491
|
+
expect(Cornucopia::Util::Configuration.record_test_start_and_end_format).to eq new_value
|
492
|
+
ensure
|
493
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_format = orig_value
|
494
|
+
end
|
495
|
+
end
|
496
|
+
end
|
497
|
+
|
460
498
|
# describe "#alternate_retry" do
|
461
499
|
# it "#can read the default" do
|
462
500
|
# expect(Cornucopia::Util::Configuration.alternate_retry).to be_falsy
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
class FakeFeature
|
4
|
+
attr_accessor :feature_name
|
5
|
+
|
6
|
+
def initialize(feature_name)
|
7
|
+
@feature_name = feature_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def name
|
11
|
+
feature_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def title
|
15
|
+
feature_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class OtherFakeScenario
|
20
|
+
attr_accessor :scenario_title
|
21
|
+
attr_accessor :line_number
|
22
|
+
|
23
|
+
def initialize(line_number, scenario_title)
|
24
|
+
@line_number = line_number
|
25
|
+
@scenario_title = scenario_title
|
26
|
+
end
|
27
|
+
|
28
|
+
def line
|
29
|
+
line_number
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class FakeScenario
|
34
|
+
attr_accessor :scenario_title
|
35
|
+
attr_accessor :feature
|
36
|
+
|
37
|
+
def initialize(feature_name, scenario_title)
|
38
|
+
@feature = FakeFeature.new(feature_name)
|
39
|
+
@scenario_title = scenario_title
|
40
|
+
end
|
41
|
+
|
42
|
+
def full_description
|
43
|
+
scenario_title
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
scenario_title
|
48
|
+
end
|
49
|
+
|
50
|
+
def title
|
51
|
+
scenario_title
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
RSpec.describe Cornucopia::Util::TestHelper do
|
56
|
+
let(:test_name) { Faker::Lorem.sentence }
|
57
|
+
|
58
|
+
describe "#cucumber_name" do
|
59
|
+
it "uses the name Unknown if the name cannot be determined" do
|
60
|
+
expect(Cornucopia::Util::TestHelper.instance.cucumber_name("fred")).to eq "Unknown"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "uses the feature title and scenario title if known" do
|
64
|
+
feature_name = Faker::Lorem.sentence
|
65
|
+
scenario_name = Faker::Lorem.sentence
|
66
|
+
scenario = FakeScenario.new(feature_name, scenario_name)
|
67
|
+
|
68
|
+
expect(Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)).to eq "#{feature_name}:#{scenario_name}"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "uses the line number if the feature name is not known" do
|
72
|
+
line_num = rand(0..5_000_000_000_000)
|
73
|
+
scenario_name = Faker::Lorem.sentence
|
74
|
+
scenario = OtherFakeScenario.new(line_num, scenario_name)
|
75
|
+
|
76
|
+
expect(Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)).to eq "Line - #{line_num}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "#spinach_name" do
|
81
|
+
it "uses the feature name and the scenario title" do
|
82
|
+
feature_name = Faker::Lorem.sentence
|
83
|
+
scenario_name = Faker::Lorem.sentence
|
84
|
+
scenario = FakeScenario.new(feature_name, scenario_name)
|
85
|
+
|
86
|
+
expect(Cornucopia::Util::TestHelper.instance.spinach_name(scenario)).to eq "#{feature_name} : #{scenario_name}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#example_name" do
|
91
|
+
it "uses the full_description" do
|
92
|
+
feature_name = Faker::Lorem.sentence
|
93
|
+
scenario_name = Faker::Lorem.sentence
|
94
|
+
scenario = FakeScenario.new(feature_name, scenario_name)
|
95
|
+
|
96
|
+
expect(Cornucopia::Util::TestHelper.instance.rspec_name(scenario)).to eq scenario_name
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "#record_test_start" do
|
101
|
+
it "calls record_test with 'Start'" do
|
102
|
+
test_name = Faker::Lorem.sentence
|
103
|
+
expect(Cornucopia::Util::TestHelper.instance).to receive(:record_test).with("Start", test_name)
|
104
|
+
|
105
|
+
Cornucopia::Util::TestHelper.instance.record_test_start(test_name)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#record_test_end" do
|
110
|
+
it "calls record_test with 'End'" do
|
111
|
+
expect(Cornucopia::Util::TestHelper.instance).to receive(:record_test).with("End", test_name)
|
112
|
+
|
113
|
+
Cornucopia::Util::TestHelper.instance.record_test_end(test_name)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "#record_test" do
|
118
|
+
around(:each) do |example|
|
119
|
+
orig_record_test_start_and_end_in_log = Cornucopia::Util::Configuration.record_test_start_and_end_in_log
|
120
|
+
orig_record_test_start_and_end_format = Cornucopia::Util::Configuration.record_test_start_and_end_format
|
121
|
+
|
122
|
+
begin
|
123
|
+
example.run
|
124
|
+
ensure
|
125
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_in_log = orig_record_test_start_and_end_in_log
|
126
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_format = orig_record_test_start_and_end_format
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "record_test_start_and_end_in_log is false" do
|
131
|
+
before(:each) do
|
132
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_in_log = false
|
133
|
+
end
|
134
|
+
|
135
|
+
it "does not log anything" do
|
136
|
+
allow(Rails.logger).to receive(:error).and_call_original
|
137
|
+
expect(Rails.logger).not_to receive(:error).with("******** Start: #{test_name}", )
|
138
|
+
|
139
|
+
Cornucopia::Util::TestHelper.instance.record_test("Start", test_name)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "record_test_start_and_end_in_log is true" do
|
144
|
+
before(:each) do
|
145
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_in_log = true
|
146
|
+
end
|
147
|
+
|
148
|
+
it "records a log message" do
|
149
|
+
allow(Rails.logger).to receive(:error).and_call_original
|
150
|
+
expect(Rails.logger).to receive(:error).with("******** Start: #{test_name}",)
|
151
|
+
|
152
|
+
Cornucopia::Util::TestHelper.instance.record_test("Start", test_name)
|
153
|
+
end
|
154
|
+
|
155
|
+
it "uses a custom format" do
|
156
|
+
some_text = Faker::Lorem.sentence
|
157
|
+
|
158
|
+
Cornucopia::Util::Configuration.record_test_start_and_end_format = "%{start_end} #{some_text} %{test_name}"
|
159
|
+
allow(Rails.logger).to receive(:error).and_call_original
|
160
|
+
expect(Rails.logger).to receive(:error).with("Start #{some_text} #{test_name}",)
|
161
|
+
|
162
|
+
Cornucopia::Util::TestHelper.instance.record_test("Start", test_name)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
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.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- lib/cornucopia/util/report_builder.rb
|
255
255
|
- lib/cornucopia/util/report_formatters.rb
|
256
256
|
- lib/cornucopia/util/report_table.rb
|
257
|
+
- lib/cornucopia/util/test_helper.rb
|
257
258
|
- lib/cornucopia/version.rb
|
258
259
|
- lib/tasks/cornucopia_tasks.rake
|
259
260
|
- spec/dummy/README.rdoc
|
@@ -315,6 +316,7 @@ files:
|
|
315
316
|
- spec/lib/util/report_formatters_spec.rb
|
316
317
|
- spec/lib/util/report_table_exception_spec.rb
|
317
318
|
- spec/lib/util/report_table_spec.rb
|
319
|
+
- spec/lib/util/test_helper_spec.rb
|
318
320
|
- spec/pages/cornucopia_report_app.rb
|
319
321
|
- spec/pages/google/email_page.rb
|
320
322
|
- spec/pages/google/login_page.rb
|
@@ -405,6 +407,7 @@ test_files:
|
|
405
407
|
- spec/lib/util/report_formatters_spec.rb
|
406
408
|
- spec/lib/util/report_table_exception_spec.rb
|
407
409
|
- spec/lib/util/report_table_spec.rb
|
410
|
+
- spec/lib/util/test_helper_spec.rb
|
408
411
|
- spec/pages/cornucopia_report_app.rb
|
409
412
|
- spec/pages/google/email_page.rb
|
410
413
|
- spec/pages/google/login_page.rb
|