drapergem/draper

View on GitHub
lib/generators/mini_test/decorator_generator.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'generators/mini_test'

module MiniTest
  module Generators
    class DecoratorGenerator < Base
      def self.source_root
        File.expand_path("templates", __dir__)
      end

      class_option :spec, type: :boolean, default: false, desc: "Use MiniTest::Spec DSL"

      check_class_collision suffix: "DecoratorTest"

      def create_test_file
        template_type = options[:spec] ? "spec" : "test"
        template "decorator_#{template_type}.rb", File.join("test/decorators", class_path, "#{singular_name}_decorator_test.rb")
      end
    end
  end
end