Class: Moto::Modes::Validate::TestValidator
- Inherits:
-
Object
- Object
- Moto::Modes::Validate::TestValidator
- Defined in:
- lib/modes/validate/test_validator.rb
Instance Method Summary collapse
-
#initialize(tests_metadata, validation_options, test_reporter) ⇒ TestValidator
constructor
A new instance of TestValidator.
- #run ⇒ Object
Constructor Details
#initialize(tests_metadata, validation_options, test_reporter) ⇒ TestValidator
Returns a new instance of TestValidator.
15 16 17 18 19 20 |
# File 'lib/modes/validate/test_validator.rb', line 15 def initialize(, , test_reporter) = = @test_reporter = test_reporter end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/modes/validate/test_validator.rb', line 22 def run @test_reporter.report_start_run test_generator = Moto::Test::Generator.new .each do || tests = test_generator.get_test_with_variants(, 1) tests.each do |test| @test_reporter.report_start_test(test.status, test.) test.status.initialize_run # Validate if tags are not empty if [:has_tags] && ..empty? test.status.log_exception(Exceptions::TestForcedFailure.new('No tags.')) end # Validate if test description was provided if [:has_description] && .description.empty? test.status.log_exception(Exceptions::TestForcedFailure.new('No description.')) end # Validate if tags contain entries only from the whitelist if .key?(:tag_whitelist) ..each do |tag| if ![:tag_whitelist].include?(tag) test.status.log_exception(Exceptions::TestForcedFailure.new("Tags contain non-whitelisted entry: #{tag}")) break end end end # Validate if provided regex is found within tags if .key?(:tags_regex_positive) = ..join(',') regexp = Regexp.new([:tags_regex_positive]) result = regexp.match() if result.nil? test.status.log_exception(Exceptions::TestForcedFailure.new("Positive match should have been found in: #{metadata.tags.join(',')}")) end end # Validate if provided regex is NOT found within tags if .key?(:tags_regex_negative) = ..join(',') regexp = Regexp.new([:tags_regex_negative]) result = regexp.match() if !result.nil? test.status.log_exception(Exceptions::TestForcedFailure.new("Negative match shouldn't have been found in: #{metadata.tags.join(',')}")) end end test.status.finalize_run @test_reporter.report_end_test(test.status) end end @test_reporter.report_end_run # Exit application with code that represents status of test run Kernel.exit(@test_reporter.run_status.bitmap) end |