Class: RailsProof::AiTestWriter
- Inherits:
-
Object
- Object
- RailsProof::AiTestWriter
- Defined in:
- lib/rails_proof/ai_test_writer.rb
Defined Under Namespace
Classes: InvalidConcern
Instance Attribute Summary collapse
-
#concerns ⇒ Object
readonly
Returns the value of attribute concerns.
-
#superclass ⇒ Object
readonly
Returns the value of attribute superclass.
-
#test_class_name ⇒ Object
readonly
Returns the value of attribute test_class_name.
Instance Method Summary collapse
-
#initialize(test_class_name:, superclass:, concerns:) ⇒ AiTestWriter
constructor
A new instance of AiTestWriter.
- #render ⇒ Object
- #render_test_file ⇒ Object
Constructor Details
#initialize(test_class_name:, superclass:, concerns:) ⇒ AiTestWriter
Returns a new instance of AiTestWriter.
7 8 9 10 11 |
# File 'lib/rails_proof/ai_test_writer.rb', line 7 def initialize(test_class_name:, superclass:, concerns:) @test_class_name = test_class_name @superclass = superclass @concerns = concerns end |
Instance Attribute Details
#concerns ⇒ Object (readonly)
Returns the value of attribute concerns.
5 6 7 |
# File 'lib/rails_proof/ai_test_writer.rb', line 5 def concerns @concerns end |
#superclass ⇒ Object (readonly)
Returns the value of attribute superclass.
5 6 7 |
# File 'lib/rails_proof/ai_test_writer.rb', line 5 def superclass @superclass end |
#test_class_name ⇒ Object (readonly)
Returns the value of attribute test_class_name.
5 6 7 |
# File 'lib/rails_proof/ai_test_writer.rb', line 5 def test_class_name @test_class_name end |
Instance Method Details
#render ⇒ Object
13 14 15 16 17 |
# File 'lib/rails_proof/ai_test_writer.rb', line 13 def render concerns.map do |concern| indent(test_code_for(concern), 2) end.join("\n\n") end |
#render_test_file ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails_proof/ai_test_writer.rb', line 19 def render_test_file [ 'require "test_helper"', "", "class #{test_class_name} < #{superclass}", render, "end", "" ].join("\n") end |