module Rails::Generators::Testing::Behaviour
def run_generator(args = default_arguments, config = {})
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