Class: TestUnit::Generators::ScaffoldGenerator

Inherits:
Base show all
Includes:
Rails::Generators::ResourceHelpers
Defined in:
lib/rails/generators/test_unit/scaffold/scaffold_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Rails::Generators::ResourceHelpers

included, #initialize

Methods inherited from Rails::Generators::NamedBase

check_class_collision, #initialize

Methods inherited from Rails::Generators::Base

add_shebang_option!, banner, base_name, base_root, class_option, default_aliases_for_option, default_for_option, default_generator_root, default_source_root, default_value_for_option, desc, exit_on_failure?, generator_name, hide!, hook_for, hooks, inherited, namespace, prepare_for_invocation, remove_hook_for, source_root, usage_path

Methods included from Rails::Generators::Actions

#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initialize, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor

Instance Method Details

#create_test_filesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rails/generators/test_unit/scaffold/scaffold_generator.rb', line 21

def create_test_files
  template_file = options.api? ? "api_functional_test.rb" : "functional_test.rb"
  template template_file,
           File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")

  # Generate system tests if this isn't an API only app and the system
  # tests option is true
  if !options.api? && options[:system_tests] == "true"
    if !File.exist?(File.join("test/application_system_test_case.rb"))
      template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
    end

    template "system_test.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
  end
end

#fixture_nameObject



37
38
39
40
41
42
43
44
# File 'lib/rails/generators/test_unit/scaffold/scaffold_generator.rb', line 37

def fixture_name
  @fixture_name ||=
    if mountable_engine?
      (namespace_dirs + [table_name]).join("_")
    else
      table_name
    end
end