Class: Cornucopia::Util::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cornucopia/util/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/cornucopia/util/configuration.rb', line 16

def initialize
  @configurations = Cornucopia::Util::GenericSettings.new

  configurations.order_seed                       = nil
  configurations.rand_seed                        = nil
  configurations.rand_context_seed                = nil
  configurations.rand_suite_seed                  = nil
  configurations.user_log_files                   = {}
  configurations.default_num_lines                = 500
  configurations.grab_logs                        = true
  configurations.backup_logs_on_failure           = false
  configurations.print_timeout_min                = 10
  configurations.selenium_cache_retry_count       = 5
  configurations.analyze_find_exceptions          = true
  configurations.analyze_selector_exceptions      = true
  configurations.ignore_finder_errors_on_success  = true
  configurations.ignore_has_selector_errors       = true
  configurations.record_test_start_and_end_in_log = true
  configurations.record_test_start_and_end_format = "******** %{start_end}: %{test_name}"
  configurations.retry_with_found                 = false
  configurations.retry_match_with_found           = false
  configurations.open_report_settings             = { default: false }
  configurations.base_folder                      = "cornucopia_report"
  configurations.benchmark                        = false
  configurations.report_postfix                   = ""

  # configurations.alternate_retry            = false

  configurations.default_configuration = {
      rspec:                       {
          min_fields:           [
                                    :example__full_description,
                                    :example__location,
                                    :example__exception__message,
                                    :example__exception__backtrace
                                ],
          more_info_fields:     [
                                    :example__exception__class__name,
                                    :example,
                                    :seeds__seed_value,
                                    :seeds__context_seed_value,
                                    :seeds__suite_seed_value,
                                    :example__example_group_instance,
                                    :example__metadata__caller,
                                    {
                                        report_element: :rspec__configuration__seed,
                                        report_options: { ignore_missing: true }
                                    },
                                    {
                                        report_element: :rspec__configuration__ordering_manager__seed,
                                        report_options: { ignore_missing: true }
                                    },
                                    :logs,
                                    :capybara_page_diagnostics,
                                    {
                                        report_element: :example__exception__all_exceptions,
                                        report_options: { ignore_missing:  true,
                                                          format_object:   Cornucopia::Util::MultipleExceptionFormatter,
                                                          format_function: :format_backtrace }
                                    }
                                ],
          expand_fields:        [
                                    :example,
                                    :example__example_group_instance____memoized,
                                    :example__example_group_instance____memoized__memoized,
                                    :example__example_group_instance__response,
                                    :example__example_group_instance__controller,
                                    :example__example_group_instance__request,
                                    :example__example_group_instance__request__env,
                                    :example__example_group_instance
                                ],
          expand_inline_fields: [
                                    :example__example_group_instance____memoized,
                                    :example__example_group_instance____memoized__memoized
                                ],
          exclude_fields:       [
                                    :example__fixture_connections,
                                    :example,
                                    :example__reporter,
                                    :example__example_group_instance,
                                    :example__example_group_instance____memoized__mutex,
                                    :example__example_group_instance__controller___request,
                                    :example__example_group_instance__controller___response,
                                    :example__example_group_instance__controller___routes,
                                    :example__example_group_instance__request__filtered_env,
                                    :example__example_group_instance__routes,
                                    :example__example_group_instance___routes,
                                    "example__example_group_instance__request__env__action_dispatch.routes",
                                    "example__example_group_instance__request__env__action_controller.instance",
                                ],
      },
      cucumber:                    {
          min_fields:           [
                                    {
                                        report_element: :scenario__feature__title,
                                        report_options: { label: "feature", ignore_missing: true }
                                    },
                                    {
                                        report_element: :scenario__feature__name,
                                        report_options: { label: "feature", ignore_missing: true }
                                    },
                                    {
                                        report_element: :scenario__feature__location,
                                        # report_options: { format: ->(value) { "#{value.file}:#{value.line}" } }
                                        report_options: { format_object:   Cornucopia::Util::CucumberFormatter,
                                                          format_function: :format_location }
                                    },
                                    {
                                        report_element: :scenario__title,
                                        report_options: { label: "scenario" }
                                    },
                                    {
                                        report_element: :scenario__location,
                                        report_options: { format_object:   Cornucopia::Util::CucumberFormatter,
                                                          format_function: :format_location }
                                    },
                                    :scenario__exception__message,
                                    :scenario__exception__backtrace
                                ],
          more_info_fields:     [
                                    :scenario__exception__class__name,
                                    :scenario,
                                    :scenario__seed_value,
                                    # :scenario__feature__comment,
                                    :scenario__feature__keyword,
                                    :scenario__feature__description,
                                    {
                                        report_element: :scenario__feature__gherkin_statement,
                                        report_options: { ignore_missing: true }
                                    },
                                    :scenario__feature__tags,
                                    # :scenario__current_visitor__configuration,
                                    :cucumber,
                                    :logs,
                                    :capybara_page_diagnostics,
                                    {
                                        report_element: :scenario__exception__all_exceptions,
                                        report_options: { ignore_missing: true }
                                    }
                                ],
          expand_fields:        [
                                    :scenario,
                                    :cucumber
                                ],
          expand_inline_fields: [
                                ],
          exclude_fields:       [
                                    :scenario__background,
                                    :scenario__feature,
                                    :scenario__current_visitor,
                                    :scenario__raw_steps,
                                    :scenario__title,
                                    :scenario__location,
                                    :cucumber____cucumber_runtime,
                                    :cucumber____natural_language,
                                    :cucumber___rack_test_sessions,
                                    :cucumber___rack_mock_sessions,
                                    :cucumber__integration_session
                                ]
      },
      cucumber_outline:            {
          min_fields:           [
                                    {
                                        report_element: :scenario__scenario_outline__name,
                                        report_options: { label: "feature_outline" }
                                    },
                                    {
                                        report_element: :scenario__name,
                                        report_options: { label: "scenario_example" }
                                    },
                                    {
                                        report_element: :scenario__scenario_outline__example_sections__0__0__0,
                                        # report_options: { format: ->(value) { "#{value.file}:#{value.line}" } }
                                        report_options: { format_object:   Cornucopia::Util::CucumberFormatter,
                                                          format_function: :format_location }
                                    },
                                    :scenario__exception__message,
                                    :scenario__exception__backtrace
                                ],
          more_info_fields:     [
                                    :scenario__exception__class__name,
                                    :scenario,
                                    :scenario__scenario_outline__example_sections__0__1__comments,
                                    :scenario__scenario_outline__example_sections__0__1__keyword,
                                    :scenario__scenario_outline__example_sections__0__1__description,
                                    :scenario__source_tag_names,
                                    :scenario__scenario_outline__example_sections__0__1__tags,
                                    :scenario__scenario_outline__example_sections__0__0,
                                    :scenario__scenario_outline,
                                    :cucumber,
                                    :logs,
                                    :capybara_page_diagnostics,
                                    {
                                        report_element: :scenario__exception__all_exceptions,
                                        report_options: { ignore_missing: true }
                                    }
                                ],
          expand_fields:        [
                                    :scenario,
                                    :scenario__scenario_outline,
                                    :cucumber
                                ],
          expand_inline_fields: [
                                ],
          exclude_fields:       [
                                    :scenario__background,
                                    :scenario__scenario_outline__background,
                                    :scenario__table,
                                    :scenario__feature,
                                    :scenario__current_visitor,
                                    :scenario__raw_steps,
                                    :scenario__title,
                                    :cucumber____cucumber_runtime,
                                    :cucumber____natural_language,
                                    :cucumber___rack_test_sessions,
                                    :cucumber___rack_mock_sessions,
                                    :cucumber__integration_session
                                ]
      },
      spinach:                     {
          min_fields:           [
                                    :failure_description,
                                    :running_scenario__feature__name,
                                    :running_scenario__name,
                                    :running_scenario__line,
                                    :step_data__name,
                                    :step_data__line,
                                    :exception__message,
                                    :exception__backtrace
                                ],
          more_info_fields:     [
                                    :exception__class__name,
                                    :running_scenario__feature__tags,
                                    :running_scenario,
                                    :step_data,
                                    :step_definitions,
                                    :logs,
                                    :capybara_page_diagnostics,
                                    {
                                        report_element: :exception__all_exceptions,
                                        report_options: { ignore_missing: true }
                                    }
                                ],
          expand_fields:        [
                                    :running_scenario,
                                    :step_data,
                                    :step_definitions
                                ],
          expand_inline_fields: [
                                ],
          exclude_fields:       [
                                    :running_scenario__feature,
                                    :step_data__scenario__feature,
                                    :running_scenario__name,
                                    :running_scenario__line,
                                    :step_data__name,
                                    :step_data__line
                                ]
      },
      capybara_page_diagnostics:   {
          min_fields:           [
                                    :capybara__page_url,
                                    :capybara__title,
                                    :capybara__screen_shot
                                ],
          more_info_fields:     [
                                    :capybara,
                                    :capybara__other_windows,
                                ],
          expand_fields:        [
                                    :capybara,
                                    :capybara__other_windows,
                                    "capybara__other_windows__*",
                                ],
          expand_inline_fields: [
                                    :capybara,
                                ],
          exclude_fields:       [
                                    :capybara__page_url,
                                    :capybara__screen_shot,
                                    :capybara__title,
                                    :capybara__options,
                                    :capybara__report,
                                    :capybara__table,
                                    :capybara__unsupported_list,
                                    :capybara__allow_other_windows,
                                    :capybara__iterating,
                                    :capybara__session,
                                    :capybara__driver,
                                    :capybara__window_handles,
                                    :capybara__current_window,
                                    "capybara__other_windows__*__options",
                                    "capybara__other_windows__*__report",
                                    "capybara__other_windows__*__table",
                                    "capybara__other_windows__*__unsupported_list",
                                    "capybara__other_windows__*__allow_other_windows",
                                    "capybara__other_windows__*__iterating",
                                    "capybara__other_windows__*__session",
                                    "capybara__other_windows__*__driver",
                                    "capybara__other_windows__*__window_handles",
                                    "capybara__other_windows__*__current_window"
                                ],
          leaf_options:         [
                                    { report_element: [:html_source,
                                                       :html_frame,
                                                       :screen_shot
                                                      ],
                                      report_options: { prevent_shrink:      true,
                                                        exclude_code_block:  true,
                                                        do_not_pretty_print: true
                                      }
                                    },
                                    { report_element: [:html_file],
                                      report_options: { exclude_code_block: true },
                                    }
                                ]
      },
      capybara_finder_diagnostics: {
          min_fields:           [
                                    :finder__function_name,
                                    :finder__args__0,
                                    :finder__search_args,
                                    :finder__options,
                                    :exception__message,
                                    :exception__backtrace
                                ],
          more_info_fields:     [
                                    :exception__class__name,
                                    :finder,
                                    :capybara_page_diagnostics,
                                    {
                                        report_element: :exception__all_exceptions,
                                        report_options: { ignore_missing: true }
                                    }
                                ],
          expand_fields:        [
                                    :finder,
                                    :finder__args,
                                    :finder__all_elements,
                                    :finder__all_other_elements,
                                    "finder__all_elements__*",
                                    "finder__all_other_elements__*",
                                    "finder__all_elements__*__native_size",
                                    "finder__all_other_elements__*__native_size",
                                    "finder__all_elements__*__elem_location",
                                    "finder__all_other_elements__*__elem_location",
                                    :finder__search_args,
                                    :finder__options
                                ],
          expand_inline_fields: [
                                    :finder
                                ],
          exclude_fields:       [
                                    :finder__return_value,
                                    :finder__function_name,
                                    :finder__args__0,
                                    :finder__search_args,
                                    :finder__options,
                                    :finder__report_options,
                                    :finder__test_object,
                                    "finder__all_elements__*__found_element",
                                    "finder__all_other_elements__*__found_element"
                                ]
      }
  }

  configurations.configured_reports = {}
end

Instance Attribute Details

#configurationsObject

Returns the value of attribute configurations.



14
15
16
# File 'lib/cornucopia/util/configuration.rb', line 14

def configurations
  @configurations
end

Class Method Details

.add_log_file(log_file_name, options = {}) ⇒ Object

Adds the specified log file to the list of log files to capture. If the log file is already in the list, the passed in options will be merged with the existing options. See Cornucopia::LogCapture



526
527
528
529
530
# File 'lib/cornucopia/util/configuration.rb', line 526

def add_log_file(log_file_name, options = {})
  Cornucopia::Util::Configuration.instance.configurations.user_log_files[log_file_name] ||= {}
  Cornucopia::Util::Configuration.instance.configurations.user_log_files[log_file_name] =
      Cornucopia::Util::Configuration.instance.configurations.user_log_files[log_file_name].merge options
end

.analyze_find_exceptionsObject

This setting is used by the Capybara utilities.

When Capybara::Node.find throws an exception, if this is set, the system will try to use the FinderDiagnostics to output some diagnostic information about the page and the finder to try to assist in determining what happened.



620
621
622
# File 'lib/cornucopia/util/configuration.rb', line 620

def analyze_find_exceptions
  Cornucopia::Util::Configuration.instance.configurations.analyze_find_exceptions
end

.analyze_find_exceptions=(value) ⇒ Object



624
625
626
# File 'lib/cornucopia/util/configuration.rb', line 624

def analyze_find_exceptions=(value)
  Cornucopia::Util::Configuration.instance.configurations.analyze_find_exceptions = value
end

.analyze_selector_exceptionsObject

This setting is used by the Capybara utilities.

When Capybara::Node.analyze_selector throws an exception, if this is set, the system will try to use the FinderDiagnostics to output some diagnostic information about the page and the selector to try to assist in determining what happened.



633
634
635
# File 'lib/cornucopia/util/configuration.rb', line 633

def analyze_selector_exceptions
  Cornucopia::Util::Configuration.instance.configurations.analyze_selector_exceptions
end

.analyze_selector_exceptions=(value) ⇒ Object



637
638
639
# File 'lib/cornucopia/util/configuration.rb', line 637

def analyze_selector_exceptions=(value)
  Cornucopia::Util::Configuration.instance.configurations.analyze_selector_exceptions = value
end

.auto_open_report_after_generation(open_report, report_name = nil) ⇒ Object

To make it easier to know about and to see the reports, this configuration will cause a report to be automatically opened if there is anything to report when the report is closed.

The posible values for report_name are:

nil
"rspec_report"
"cucumber_report"
"spinach_report"


704
705
706
# File 'lib/cornucopia/util/configuration.rb', line 704

def auto_open_report_after_generation(open_report, report_name = nil)
  Cornucopia::Util::Configuration.instance.configurations.open_report_settings[report_name || :default] = open_report
end

.backup_logs_on_failureObject



495
496
497
# File 'lib/cornucopia/util/configuration.rb', line 495

def backup_logs_on_failure
  Cornucopia::Util::Configuration.instance.configurations.backup_logs_on_failure
end

.backup_logs_on_failure=(value) ⇒ Object

backup_logs_on_failure causes the system to copy the log files at the end of the report cycle if there were any errors during the creation of the report system.

The system will try to grab the following log files:

* Rails.env.log
* any user specified logs

The log capture is done with a simple file copy.

Related options:

user_log_files
num_lines
add_log_file
remove_log_file
grab_logs


491
492
493
# File 'lib/cornucopia/util/configuration.rb', line 491

def backup_logs_on_failure=(value)
  Cornucopia::Util::Configuration.instance.configurations.backup_logs_on_failure = value
end

.base_folderObject

Sets or returns the name of the folder to generate reports into.

Default: “cornucopia_report”



744
745
746
# File 'lib/cornucopia/util/configuration.rb', line 744

def base_folder
  Cornucopia::Util::Configuration.instance.configurations.base_folder
end

.base_folder=(value) ⇒ Object



748
749
750
# File 'lib/cornucopia/util/configuration.rb', line 748

def base_folder=(value)
  Cornucopia::Util::Configuration.instance.configurations.base_folder = value
end

.benchmarkObject

Turns benchmarking on or off.

Defaults to false.



782
783
784
# File 'lib/cornucopia/util/configuration.rb', line 782

def benchmark
  Cornucopia::Util::Configuration.instance.configurations.benchmark
end

.benchmark=(value) ⇒ Object



786
787
788
# File 'lib/cornucopia/util/configuration.rb', line 786

def benchmark=(value)
  Cornucopia::Util::Configuration.instance.configurations.benchmark = value
end

.context_seedObject



412
413
414
# File 'lib/cornucopia/util/configuration.rb', line 412

def context_seed
  Cornucopia::Util::Configuration.instance.configurations.rand_context_seed
end

.context_seed=(value) ⇒ Object

rand_context_seed is the seed value used to seed the srand function at the start of a context. This is done to allow tests with random elements in them to be repeatable. If a test fails, simply set Cornucopia::Util::Configuration.rand_context_seed to the value of the failed tests context_seed value (output in the stdout and the generated report) and run the test again. This should re-run the exact same test, resulting in a repeatable test even with randomization in it.



407
408
409
410
# File 'lib/cornucopia/util/configuration.rb', line 407

def context_seed=(value)
  Cornucopia::Util::Configuration.instance.configurations.rand_context_seed = value
  srand(value) if value
end

.default_num_lines=(value) ⇒ Object

default_num_lines sets the default number of lines to extract from the log file



518
519
520
# File 'lib/cornucopia/util/configuration.rb', line 518

def default_num_lines=(value)
  Cornucopia::Util::Configuration.instance.configurations.default_num_lines = value
end

.default_report_configuration(report_name) ⇒ Object

returns the report configuration object for that type of report

values for report_name:

:rspec
:cucumber
:spinach
:capybara_page_diagnostics


573
574
575
# File 'lib/cornucopia/util/configuration.rb', line 573

def default_report_configuration(report_name)
  Cornucopia::Util::Configuration.instance.configurations.default_configuration[report_name].try :clone
end

.grab_logsObject



472
473
474
# File 'lib/cornucopia/util/configuration.rb', line 472

def grab_logs
  Cornucopia::Util::Configuration.instance.configurations.grab_logs
end

.grab_logs=(value) ⇒ Object

grab_logs indicates if the system should try to automatically grab a tail of the log file if outputing a diagnostics report.

The system will try to grab the following log files:

* Rails.env.log
* any user specified logs

The log capture is done by reading from the end of the file of the log file. If the log file cannot be found, or if the system cannot open the file (no access rights, etc.) nothing will be output.

Related options:

user_log_files
num_lines
add_log_file
remove_log_file


468
469
470
# File 'lib/cornucopia/util/configuration.rb', line 468

def grab_logs=(value)
  Cornucopia::Util::Configuration.instance.configurations.grab_logs = value
end

.ignore_finder_errors_on_successObject

This setting is used by the report builder.

If a test has finder errors but still succeeds, ignore the errors and do not report them. This is useful for tests that test the existence of an element on the page using something like: expect(my_page).not_to have_page_element



646
647
648
# File 'lib/cornucopia/util/configuration.rb', line 646

def ignore_finder_errors_on_success
  Cornucopia::Util::Configuration.instance.configurations.ignore_finder_errors_on_success
end

.ignore_finder_errors_on_success=(value) ⇒ Object



650
651
652
# File 'lib/cornucopia/util/configuration.rb', line 650

def ignore_finder_errors_on_success=(value)
  Cornucopia::Util::Configuration.instance.configurations.ignore_finder_errors_on_success = value
end

.ignore_has_selector_errorsObject

This setting is used by the matcher analysis.

Generally speaking has_selector? is allowed to return true or false without needing to be to analyzed. So, the system ignores has_selector? failures and doesn’t output an analysis.

This will perform an analysis for each has_selector? failure.



660
661
662
# File 'lib/cornucopia/util/configuration.rb', line 660

def ignore_has_selector_errors
  Cornucopia::Util::Configuration.instance.configurations.ignore_has_selector_errors
end

.ignore_has_selector_errors=(value) ⇒ Object



664
665
666
# File 'lib/cornucopia/util/configuration.rb', line 664

def ignore_has_selector_errors=(value)
  Cornucopia::Util::Configuration.instance.configurations.ignore_has_selector_errors = value
end

.num_lines(log_file_name = nil) ⇒ Object

num_lines returns the number of lines that will be grabbed for a file. If no file name is supplied, or the name does not match a user file, the default log length will returned.



512
513
514
515
# File 'lib/cornucopia/util/configuration.rb', line 512

def num_lines(log_file_name = nil)
  Cornucopia::Util::Configuration.instance.configurations.user_log_files[log_file_name].try(:[], :num_lines) ||
      Cornucopia::Util::Configuration.instance.configurations.default_num_lines
end

.open_report_after_generation(report_name) ⇒ Object



708
709
710
711
712
# File 'lib/cornucopia/util/configuration.rb', line 708

def open_report_after_generation(report_name)
  open_report = Cornucopia::Util::Configuration.instance.configurations.open_report_settings[report_name]
  open_report = Cornucopia::Util::Configuration.instance.configurations.open_report_settings[:default] if open_report.nil?
  open_report
end

.order_seedObject



448
449
450
# File 'lib/cornucopia/util/configuration.rb', line 448

def order_seed
  Cornucopia::Util::Configuration.instance.configurations.order_seed
end

.order_seed=(value) ⇒ Object

order_seed is the seed value used to set the order that randomly ordered tests are run in. This is provided as a convenience method. I think it is easier to set this in rails_helper than it is to set it on the command line. This also provides a uniform method to do it.



434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/cornucopia/util/configuration.rb', line 434

def order_seed=(value)
  Cornucopia::Util::Configuration.instance.configurations.order_seed = value

  if value
    if RSpec.configuration.respond_to?(:seed)
      RSpec.configuration.seed = value
    else
      # :nocov:
      RSpec.configuration.ordering_manager.seed = value
      # :nocov:
    end
  end
end

Sets or returns the minimum amount of time in seconds to allow for the printing of variables. If it is available, the larger of this value and Capybara.default_wait_time will be used.

This value exists to prevent the printing of a value on a report from taking too long and holding up the system. If it takes longer than this amount of time to get the value it probably isn’t diagnostically important.

Default: 10



585
586
587
# File 'lib/cornucopia/util/configuration.rb', line 585

def print_timeout_min
  Cornucopia::Util::Configuration.instance.configurations.print_timeout_min
end


589
590
591
# File 'lib/cornucopia/util/configuration.rb', line 589

def print_timeout_min=(value)
  Cornucopia::Util::Configuration.instance.configurations.print_timeout_min = value
end

.record_test_start_and_end_formatObject

This setting is used by the test system hooks.

This value specifies the text that is output into the log file at the start/end of a test. Two variables are passed into the format string to be inserted into the text:

* %{start_end} - This will be either "Start" or "End"
* %{test_name} - This will the the name of the test.


771
772
773
# File 'lib/cornucopia/util/configuration.rb', line 771

def record_test_start_and_end_format
  Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_format
end

.record_test_start_and_end_format=(value) ⇒ Object



775
776
777
# File 'lib/cornucopia/util/configuration.rb', line 775

def record_test_start_and_end_format=(value)
  Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_format = value
end

.record_test_start_and_end_in_logObject

This setting is used by the test system hooks.

If true (the default) this will cause the system to output a line to the Rails log indicating when a test starts and when it ends.



756
757
758
# File 'lib/cornucopia/util/configuration.rb', line 756

def record_test_start_and_end_in_log
  Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_in_log
end

.record_test_start_and_end_in_log=(value) ⇒ Object



760
761
762
# File 'lib/cornucopia/util/configuration.rb', line 760

def record_test_start_and_end_in_log=(value)
  Cornucopia::Util::Configuration.instance.configurations.record_test_start_and_end_in_log = value
end

.remove_log_file(log_file_name) ⇒ Object

Removes the specified log file from the list of log files to capture. NOTE: You cannot remove the default log file.



534
535
536
# File 'lib/cornucopia/util/configuration.rb', line 534

def remove_log_file(log_file_name)
  Cornucopia::Util::Configuration.instance.configurations.user_log_files.delete log_file_name
end

.report_configuration(report_name) ⇒ Object

returns the report configuration object for that type of report

values for report_name:

:rspec
:cucumber
:spinach
:capybara_page_diagnostics


545
546
547
548
# File 'lib/cornucopia/util/configuration.rb', line 545

def report_configuration(report_name)
  Cornucopia::Util::Configuration.instance.configurations.configured_reports[report_name] ||=
      Cornucopia::Util::ConfiguredReport.new(Cornucopia::Util::Configuration.instance.configurations.default_configuration[report_name])
end

.report_postfixObject

Adds a postfix to report names

Defaults to empty string.



793
794
795
# File 'lib/cornucopia/util/configuration.rb', line 793

def report_postfix
  Cornucopia::Util::Configuration.instance.configurations.report_postfix
end

.report_postfix=(value) ⇒ Object



797
798
799
# File 'lib/cornucopia/util/configuration.rb', line 797

def report_postfix=(value)
  Cornucopia::Util::Configuration.instance.configurations.report_postfix = value
end

.retry_match_with_foundObject

Sometimes, the analysis process found the element when it wasn’t found other ways. This will cause the match accessor to try again with the found element.

The default is true because I have been getting a fair number of false negatives.



687
688
689
# File 'lib/cornucopia/util/configuration.rb', line 687

def retry_match_with_found
  Cornucopia::Util::Configuration.instance.configurations.retry_match_with_found
end

.retry_match_with_found=(value) ⇒ Object



691
692
693
# File 'lib/cornucopia/util/configuration.rb', line 691

def retry_match_with_found=(value)
  Cornucopia::Util::Configuration.instance.configurations.retry_match_with_found = value
end

.retry_with_foundObject

Sometimes, the analysis process found the element when it wasn’t found other ways. This will cause the finder to try again with the found element.

The default is false because I haven’t seen this be useful in a while.

WARNING: Using this is unsafe. If you use it, you could get false positive

results in your test.


675
676
677
# File 'lib/cornucopia/util/configuration.rb', line 675

def retry_with_found
  Cornucopia::Util::Configuration.instance.configurations.retry_with_found
end

.retry_with_found=(value) ⇒ Object



679
680
681
# File 'lib/cornucopia/util/configuration.rb', line 679

def retry_with_found=(value)
  Cornucopia::Util::Configuration.instance.configurations.retry_with_found = value
end

.seedObject



397
398
399
# File 'lib/cornucopia/util/configuration.rb', line 397

def seed
  Cornucopia::Util::Configuration.instance.configurations.rand_seed
end

.seed=(value) ⇒ Object

rand_seed is the seed value used to seed the srand function at the start of a test suite. This is done to allow tests with random elements in them to be repeatable. If a test fails, simply set Cornucopia::Util::Configuration.rand_seed to the value of the failed tests seed value (output in the stdout and the generated report) and run the test again. This should re-run the exact same test, resulting in a repeatable test even with randomization in it.



392
393
394
395
# File 'lib/cornucopia/util/configuration.rb', line 392

def seed=(value)
  Cornucopia::Util::Configuration.instance.configurations.rand_seed = value
  srand(value) if value
end

.selenium_cache_retry_countObject

The Selenium driver can throw a StaleElementReferenceError exception sometimes. I often see it with animated items like dialog boxes and the like. When the system is looping trying to find the element or stop seeing it.

Because the element likely just disappeared between when it was found and when it was returned, trying again will often make the problem go away.

The default for this setting is 5 which will retry the find function if this error occurs.

NOTE: This should already be the default action (basically) for the Selenium

driver, yet from a purely practical standpoint, this seems to be a problem
that I've run into a lot.  I am doing it this way to see if I can reduce the
the occurrence of it.


607
608
609
# File 'lib/cornucopia/util/configuration.rb', line 607

def selenium_cache_retry_count
  Cornucopia::Util::Configuration.instance.configurations.selenium_cache_retry_count
end

.selenium_cache_retry_count=(value) ⇒ Object



611
612
613
# File 'lib/cornucopia/util/configuration.rb', line 611

def selenium_cache_retry_count=(value)
  Cornucopia::Util::Configuration.instance.configurations.selenium_cache_retry_count = value
end

.set_report_configuration(report_name, configuration) ⇒ Object

sets the report configuration object for that type of report from a configuration has that is passed in

values for report_name:

:rspec
:cucumber
:spinach
:capybara_page_diagnostics


557
558
559
560
561
562
563
564
# File 'lib/cornucopia/util/configuration.rb', line 557

def set_report_configuration(report_name, configuration)
  if configuration.is_a?(Cornucopia::Util::ConfiguredReport)
    Cornucopia::Util::Configuration.instance.configurations.configured_reports[report_name] = configuration
  else
    Cornucopia::Util::Configuration.instance.configurations.configured_reports[report_name] =
        Cornucopia::Util::ConfiguredReport.new(configuration)
  end
end

.suite_seedObject



427
428
429
# File 'lib/cornucopia/util/configuration.rb', line 427

def suite_seed
  Cornucopia::Util::Configuration.instance.configurations.rand_suite_seed
end

.suite_seed=(value) ⇒ Object

rand_suite_seed is the seed value used to seed the srand function at the start of a context. This is done to allow tests with random elements in them to be repeatable. If a test fails, simply set Cornucopia::Util::Configuration.rand_suite_seed to the value of the failed tests suite_seed value (output in the stdout and the generated report) and run the test again. This should re-run the exact same test, resulting in a repeatable test even with randomization in it.



422
423
424
425
# File 'lib/cornucopia/util/configuration.rb', line 422

def suite_seed=(value)
  Cornucopia::Util::Configuration.instance.configurations.rand_suite_seed = value
  srand(value) if value
end

.user_log_filesObject

user_log_files returns a hash of all of the log files which the user has specified are to be grabbed.

The keys are the relative paths of the log files to be grabbed, and the values are the options specified for the files. The values may be an empty hash.



505
506
507
# File 'lib/cornucopia/util/configuration.rb', line 505

def user_log_files
  Cornucopia::Util::Configuration.instance.configurations.user_log_files.clone
end