class Tset::Generators::ModelTest
Generates blank test files in the application Uses analyzers, translators, and writers to insert appropriate tests into the files.
@param command [Tset::Commands::Generate] An instance of generate command
Attributes
model_name[R]
Public Class Methods
new(command)
click to toggle source
Calls superclass method
Tset::Generators::Abstract::new
# File lib/tset/generators/model_test.rb, line 18 def initialize(command) super @model_name = name.classify cli.class.source_root(source) end
Public Instance Methods
start()
click to toggle source
# File lib/tset/generators/model_test.rb, line 25 def start assert_model_exists! opts = { model_name: @model_name } case framework when 'rspec' cli.template(source.join('model_spec.rspec.tt'), target.join("spec/models/#{ name }_spec.rb"), opts) when 'minitest' cli.template(source.join('model_test.minitest.tt'), target.join("test/models/#{ name }_test.rb"), opts) end testables = Tset::Analyzers::Model.new(name).start Tset::Writers::ModelTest.new(name, testables, framework).start! end
Private Instance Methods
assert_model_exists!()
click to toggle source
# File lib/tset/generators/model_test.rb, line 45 def assert_model_exists! unless target.join("app/models/#{ name }.rb").exist? raise Tset::Commands::Generate::Error.new("Unknown model: `#{ name }`") end end