class ShouldaMatchmakers::ModelMatcherGenerator
Public Instance Methods
create_model_matchmakers()
click to toggle source
# File lib/generators/shoulda_matchmakers/model_matcher_generator.rb, line 53 def create_model_matchmakers puts "\n" generator = "model" generator_options = options.to_hash working_generated_code_line_length = ::ShouldaMatchmakers.configuration.preferred_generated_code_line_length - 6 SpinToWin.with_spinner('ShouldaMatchmakers:ModelMatchers') do |spinner| spinner.banner('initializing...') load_application @app_active_record_descendants_names = get_app_active_record_descendants_names end puts "\n" generate_active_record_model_matchmakers(generator, generator_options, @app_active_record_descendants_names, working_generated_code_line_length) end
Private Instance Methods
generate_active_record_model_matchmakers(generator, generator_options, app_active_record_descendants_names, code_line_length)
click to toggle source
# File lib/generators/shoulda_matchmakers/model_matcher_generator.rb, line 70 def generate_active_record_model_matchmakers(generator, generator_options, app_active_record_descendants_names, code_line_length) if app_active_record_descendants_names.present? selected_app_active_record_descendants_names = filter_app_active_record_descendants_names(generator, generator_options, app_active_record_descendants_names) selected_app_active_record_descendants_names.each do |app_class_name| save_generate(app_class_name, generator) do @active_record_model_sm_model = ::ShouldaMatchmakers::Model::ActiveRecord::ActiveRecordModelSmModel.new(app_class_name, app_active_record_descendants_names, code_line_length) template_filename = File.expand_path('../../templates/model/active_record/model_spec_template.haml', File.dirname(__FILE__)) template = File.read(template_filename) create_file "#{ ::ShouldaMatchmakers.configuration.active_record_model_tests_path }/#{ app_class_name.underscore }_spec.rb", Haml::Engine.new(template, filename: template_filename, format: :html5).to_html(binding) end end end end