Class: Cornucopia::Util::Configuration
- Inherits:
-
Object
- Object
- Cornucopia::Util::Configuration
- Defined in:
- lib/cornucopia/util/configuration.rb
Constant Summary collapse
- @@configurations =
Cornucopia::Util::GenericSettings.new
Class Method Summary collapse
-
.add_log_file(log_file_name, options = {}) ⇒ Object
Adds the specified log file to the list of log files to capture.
-
.analyze_find_exceptions ⇒ Object
This setting is used by the Capybara utilities.
- .analyze_find_exceptions=(value) ⇒ Object
-
.analyze_selector_exceptions ⇒ Object
This setting is used by the Capybara utilities.
- .analyze_selector_exceptions=(value) ⇒ Object
-
.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.
-
.base_folder ⇒ Object
Sets or returns the name of the folder to generate reports into.
- .base_folder=(value) ⇒ Object
-
.default_num_lines=(value) ⇒ Object
default_num_lines sets the default number of lines to extract from the log file.
- .grab_logs ⇒ Object
-
.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.
-
.num_lines(log_file_name = nil) ⇒ Object
num_lines returns the number of lines that will be grabbed for a file.
- .open_report_after_generation(report_name) ⇒ Object
- .order_seed ⇒ Object
-
.order_seed=(value) ⇒ Object
order_seed is the seed value used to set the order that randomly ordered tests are run in.
-
.print_timeout_min ⇒ Object
Sets or returns the minimum amount of time in seconds to allow for the printing of variables.
- .print_timeout_min=(value) ⇒ Object
-
.remove_log_file(log_file_name) ⇒ Object
Removes the specified log file from the list of log files to capture.
-
.report_configuration(report_name) ⇒ Object
returns the report configuration object for that type of report.
-
.retry_match_with_found ⇒ Object
Sometimes, the analysis process found the element when it wasn't found other ways.
- .retry_match_with_found=(value) ⇒ Object
-
.retry_with_found ⇒ Object
Sometimes, the analysis process found the element when it wasn't found other ways.
- .retry_with_found=(value) ⇒ Object
- .seed ⇒ Object
-
.seed=(value) ⇒ Object
rand_seed is the seed value used to seed the srand function at the start of a test suite.
-
.selenium_cache_retry_count ⇒ Object
The Selenium driver can throw a StaleElementReferenceError exception sometimes.
- .selenium_cache_retry_count=(value) ⇒ Object
-
.user_log_files ⇒ Object
user_log_files returns a hash of all of the log files which the user has specified are to be grabbed.
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
335 336 337 338 |
# File 'lib/cornucopia/util/configuration.rb', line 335 def add_log_file(log_file_name, = {}) @@configurations.user_log_files[log_file_name] ||= {} @@configurations.user_log_files[log_file_name] = @@configurations.user_log_files[log_file_name].merge end |
.analyze_find_exceptions ⇒ Object
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.
400 401 402 |
# File 'lib/cornucopia/util/configuration.rb', line 400 def analyze_find_exceptions @@configurations.analyze_find_exceptions end |
.analyze_find_exceptions=(value) ⇒ Object
404 405 406 |
# File 'lib/cornucopia/util/configuration.rb', line 404 def analyze_find_exceptions=(value) @@configurations.analyze_find_exceptions = value end |
.analyze_selector_exceptions ⇒ Object
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.
413 414 415 |
# File 'lib/cornucopia/util/configuration.rb', line 413 def analyze_selector_exceptions @@configurations.analyze_selector_exceptions end |
.analyze_selector_exceptions=(value) ⇒ Object
417 418 419 |
# File 'lib/cornucopia/util/configuration.rb', line 417 def analyze_selector_exceptions=(value) @@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"
457 458 459 |
# File 'lib/cornucopia/util/configuration.rb', line 457 def auto_open_report_after_generation(open_report, report_name = nil) @@configurations.open_report_settings[report_name || :default] = open_report end |
.base_folder ⇒ Object
Sets or returns the name of the folder to generate reports into.
Default: "cornucopia_report"
497 498 499 |
# File 'lib/cornucopia/util/configuration.rb', line 497 def base_folder @@configurations.base_folder end |
.base_folder=(value) ⇒ Object
501 502 503 |
# File 'lib/cornucopia/util/configuration.rb', line 501 def base_folder=(value) @@configurations.base_folder = value end |
.default_num_lines=(value) ⇒ Object
default_num_lines sets the default number of lines to extract from the log file
327 328 329 |
# File 'lib/cornucopia/util/configuration.rb', line 327 def default_num_lines=(value) @@configurations.default_num_lines = value end |
.grab_logs ⇒ Object
305 306 307 |
# File 'lib/cornucopia/util/configuration.rb', line 305 def grab_logs @@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
301 302 303 |
# File 'lib/cornucopia/util/configuration.rb', line 301 def grab_logs=(value) @@configurations.grab_logs = 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.
322 323 324 |
# File 'lib/cornucopia/util/configuration.rb', line 322 def num_lines(log_file_name=nil) @@configurations.user_log_files[log_file_name].try(:[], :num_lines) || @@configurations.default_num_lines end |
.open_report_after_generation(report_name) ⇒ Object
461 462 463 464 465 |
# File 'lib/cornucopia/util/configuration.rb', line 461 def open_report_after_generation(report_name) open_report = @@configurations.open_report_settings[report_name] open_report = @@configurations.open_report_settings[:default] if open_report.nil? open_report end |
.order_seed ⇒ Object
281 282 283 |
# File 'lib/cornucopia/util/configuration.rb', line 281 def order_seed @@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.
276 277 278 279 |
# File 'lib/cornucopia/util/configuration.rb', line 276 def order_seed=(value) @@configurations.order_seed = value RSpec.configuration.seed = value if value end |
.print_timeout_min ⇒ Object
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
365 366 367 |
# File 'lib/cornucopia/util/configuration.rb', line 365 def print_timeout_min @@configurations.print_timeout_min end |
.print_timeout_min=(value) ⇒ Object
369 370 371 |
# File 'lib/cornucopia/util/configuration.rb', line 369 def print_timeout_min=(value) @@configurations.print_timeout_min = 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.
342 343 344 |
# File 'lib/cornucopia/util/configuration.rb', line 342 def remove_log_file(log_file_name) @@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
353 354 355 |
# File 'lib/cornucopia/util/configuration.rb', line 353 def report_configuration(report_name) @@configurations.configured_reports[report_name] end |
.retry_match_with_found ⇒ Object
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.
440 441 442 |
# File 'lib/cornucopia/util/configuration.rb', line 440 def retry_match_with_found @@configurations.retry_match_with_found end |
.retry_match_with_found=(value) ⇒ Object
444 445 446 |
# File 'lib/cornucopia/util/configuration.rb', line 444 def retry_match_with_found=(value) @@configurations.retry_match_with_found = value end |
.retry_with_found ⇒ Object
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.
428 429 430 |
# File 'lib/cornucopia/util/configuration.rb', line 428 def retry_with_found @@configurations.retry_with_found end |
.retry_with_found=(value) ⇒ Object
432 433 434 |
# File 'lib/cornucopia/util/configuration.rb', line 432 def retry_with_found=(value) @@configurations.retry_with_found = value end |
.seed ⇒ Object
269 270 271 |
# File 'lib/cornucopia/util/configuration.rb', line 269 def seed @@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.
264 265 266 267 |
# File 'lib/cornucopia/util/configuration.rb', line 264 def seed=(value) @@configurations.rand_seed = value srand(value) if value end |
.selenium_cache_retry_count ⇒ Object
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.
387 388 389 |
# File 'lib/cornucopia/util/configuration.rb', line 387 def selenium_cache_retry_count @@configurations.selenium_cache_retry_count end |
.selenium_cache_retry_count=(value) ⇒ Object
391 392 393 |
# File 'lib/cornucopia/util/configuration.rb', line 391 def selenium_cache_retry_count=(value) @@configurations.selenium_cache_retry_count = value end |
.user_log_files ⇒ Object
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.
315 316 317 |
# File 'lib/cornucopia/util/configuration.rb', line 315 def user_log_files @@configurations.user_log_files.clone end |