Class: RailsProof::AiTestValidator
- Inherits:
-
Object
- Object
- RailsProof::AiTestValidator
- Defined in:
- lib/rails_proof/ai_test_validator.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#test_code ⇒ Object
readonly
Returns the value of attribute test_code.
Instance Method Summary collapse
-
#initialize(test_code) ⇒ AiTestValidator
constructor
A new instance of AiTestValidator.
- #validate ⇒ Object
Constructor Details
#initialize(test_code) ⇒ AiTestValidator
Returns a new instance of AiTestValidator.
17 18 19 |
# File 'lib/rails_proof/ai_test_validator.rb', line 17 def initialize(test_code) @test_code = test_code end |
Instance Attribute Details
#test_code ⇒ Object (readonly)
Returns the value of attribute test_code.
15 16 17 |
# File 'lib/rails_proof/ai_test_validator.rb', line 15 def test_code @test_code end |
Instance Method Details
#validate ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rails_proof/ai_test_validator.rb', line 21 def validate errors = [] errors << "test code must be a nonblank string" unless nonblank? return Result.new(valid: false, errors: errors) unless errors.empty? errors << "test code is not valid Ruby" unless valid_ruby? errors << "test code must contain exactly one test declaration" unless one_test? errors << "test code must not contain a class declaration" if class_declaration? errors << "test code must not contain a require statement" if require_statement? errors << "test code must not contain Markdown code fences" if markdown_fence? Result.new( valid: errors.empty?, errors: errors ) end |