Sha256: 6473d53822f42d9a60bc971f532770583889453161f97524fe10167bc169326f

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require "generators/minitest"
require "rails/generators/resource_helpers"

module Minitest
  module Generators
    class ScaffoldGenerator < Base
      include ::Rails::Generators::ResourceHelpers

      check_class_collision suffix: "ControllerTest"

      argument :attributes, type: :array, default: [], banner: "field:type field:type"

      def create_test_files
        if options[:spec]
          template_file = "controller_spec.rb"
        else
          template_file = "controller_test.rb"
        end
        template template_file,
                 File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
      end

      private

      def attributes_hash
        return if attributes_names.empty?

        attributes_names.map do |name|
          if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?)
            "#{name}: 'secret'"
          else
            "#{name}: @#{singular_table_name}.#{name}"
          end
        end.sort.join(", ")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
minitest-rails-2.1.0 lib/generators/minitest/scaffold/scaffold_generator.rb
minitest-rails-2.0.3 lib/generators/minitest/scaffold/scaffold_generator.rb
minitest-rails-2.0.2 lib/generators/minitest/scaffold/scaffold_generator.rb
minitest-rails-2.0.1 lib/generators/minitest/scaffold/scaffold_generator.rb
minitest-rails-2.0.0 lib/generators/minitest/scaffold/scaffold_generator.rb
minitest-rails-2.0.0.beta1 lib/generators/minitest/scaffold/scaffold_generator.rb