module Rails::Generators::Testing::Behaviour

def create_generated_attribute(attribute_type, name = "test", index = nil)

create_generated_attribute(:string, "name")

attribute type and, optionally, the attribute name:
Create a Rails::Generators::GeneratedAttribute by supplying the
def create_generated_attribute(attribute_type, name = "test", index = nil)
  Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(":"))
end

def destination_root_is_set?

def destination_root_is_set?
  raise "You need to configure your Rails::Generators::TestCase destination root." unless destination_root
end

def ensure_current_path

def ensure_current_path
  cd current_path
end

def generator(args = default_arguments, options = {}, config = {})

Instantiate the generator.
def generator(args = default_arguments, options = {}, config = {})
  @generator ||= generator_class.new(args, options, config.reverse_merge(destination_root: destination_root))
end

def migration_file_name(relative)

def migration_file_name(relative)
  absolute = File.expand_path(relative, destination_root)
  dirname, file_name = File.dirname(absolute), File.basename(absolute).delete_suffix(".rb")
  Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
end

def prepare_destination # :doc:

:doc:
Clears all files and directories in destination.
def prepare_destination # :doc:
  rm_rf(destination_root)
  mkdir_p(destination_root)
end

def run_generator(args = default_arguments, config = {})

printed by the generator.
You can provide a configuration hash as second argument. This method returns the output

end
end
assert_no_file "config/database.yml"
run_generator %w(myapp --skip-active-record)
test "database.yml is not created when skipping Active Record" do

setup :prepare_destination
destination File.expand_path("../tmp", __dir__)
tests AppGenerator
class AppGeneratorTest < Rails::Generators::TestCase

command line arguments:
Runs the generator configured for this class. The first argument is an array like
def run_generator(args = default_arguments, config = {})
  capture(:stdout) do
    args += ["--skip-bundle"] unless args.include?("--no-skip-bundle") || args.include?("--dev")
    args += ["--skip-bootsnap"] unless args.include?("--no-skip-bootsnap") || args.include?("--skip-bootsnap")
    generator_class.start(args, config.reverse_merge(destination_root: destination_root))
  end
end