Class: Kowl::TestGenerator

Inherits:
Generators::Base show all
Defined in:
lib/kowl/generators/test_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

default_source_root, source_paths

Methods included from Docker

#alpine_docker_dependencies, #app_js_volumes, #app_volumes, #db_volumes, #debian_database_dependencies, #debian_docker_dependencies, #docker_app_command, #docker_compose_database_string, #docker_databases, #docker_depends_on, #docker_port_watcher, #docker_redis_service, #docker_sidekiq_service, #docker_variables, #docker_volumes, #docker_webpacker_service, #dockerfile_database_args, #dockerfile_migration_snip, #js_volumes, #mysql_volumes, #postgresql_volumes, #redis_volumes

Methods included from Actions

#add_extension_routes, #add_package, #append_to_file, #database_route, #dev_config, #dup_file, #file_exists?, #mailer_gems, #mailer_route, #mk_dir, #move_file, #pry_gems, #rails_cmd, #remove_dir, #remove_file, #remove_gem, #replace_string_in_file, #robocop_test_engine, #sidekiq_route, #template_linter_gems

Instance Method Details

#copy_factoriesObject

Copy over basic factory bot files



30
31
32
# File 'lib/kowl/generators/test_generator.rb', line 30

def copy_factories
  directory 'factories', "#{(options[:test_engine] == 'rspec' ? 'spec' : 'test')}/factories", force: true
end

#copy_minitest_filesObject

If using minitest copy over a few basic tests and support files



20
21
22
# File 'lib/kowl/generators/test_generator.rb', line 20

def copy_minitest_files
  directory('minitest', 'test') if options[:test_engine] == 'minitest'
end

#copy_rspec_filesObject

If using rspec copy over a few basic tests and support files



25
26
27
# File 'lib/kowl/generators/test_generator.rb', line 25

def copy_rspec_files
  directory('rspec', 'spec') if options[:test_engine] == 'rspec'
end

#remove_if_no_auth_requiredObject

If noauth is specified, remove the policies tests



35
36
37
38
39
40
# File 'lib/kowl/generators/test_generator.rb', line 35

def remove_if_no_auth_required
  return unless options[:noauth]

  remove_dir('spec/policies') if options[:test_engine] == 'rspec'
  remove_dir('test/policies') if options[:test_engine] == 'minitest'
end

#remove_old_testsObject

Remove default generate4d test and spec files



14
15
16
17
# File 'lib/kowl/generators/test_generator.rb', line 14

def remove_old_tests
  remove_dir('test')
  remove_dir('spec')
end