Class: RailsProof::TestWriter
- Inherits:
-
Object
- Object
- RailsProof::TestWriter
- Defined in:
- lib/rails_proof/test_writer.rb
Instance Attribute Summary collapse
-
#concerns ⇒ Object
readonly
Returns the value of attribute concerns.
-
#model_class_name ⇒ Object
readonly
Returns the value of attribute model_class_name.
Instance Method Summary collapse
-
#initialize(model_class_name:, concerns:) ⇒ TestWriter
constructor
A new instance of TestWriter.
- #render ⇒ Object
- #render_test_file ⇒ Object
Constructor Details
#initialize(model_class_name:, concerns:) ⇒ TestWriter
Returns a new instance of TestWriter.
5 6 7 8 |
# File 'lib/rails_proof/test_writer.rb', line 5 def initialize(model_class_name:, concerns:) @model_class_name = model_class_name @concerns = concerns end |
Instance Attribute Details
#concerns ⇒ Object (readonly)
Returns the value of attribute concerns.
3 4 5 |
# File 'lib/rails_proof/test_writer.rb', line 3 def concerns @concerns end |
#model_class_name ⇒ Object (readonly)
Returns the value of attribute model_class_name.
3 4 5 |
# File 'lib/rails_proof/test_writer.rb', line 3 def model_class_name @model_class_name end |
Instance Method Details
#render ⇒ Object
10 11 12 13 14 |
# File 'lib/rails_proof/test_writer.rb', line 10 def render concerns.map do |concern| indent(render_concern(concern), 2) end.join("\n\n") end |
#render_test_file ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rails_proof/test_writer.rb', line 16 def render_test_file [ 'require "test_helper"', "", "class #{model_class_name}Test < ActiveSupport::TestCase", render, "end", "" ].join("\n") end |