Class: Padrino::Generators::AdminControllerTest
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Padrino::Generators::AdminControllerTest
- Includes:
- Padrino::Generators, Actions, Components::Actions, Runner, Thor::Actions
- Defined in:
- lib/lazy-head-gen/admin_controller_test.rb
Class Method Summary collapse
-
.banner ⇒ Object
Defines the banner for this CLI generator.
-
.source_root ⇒ Object
Define the source template root.
Instance Method Summary collapse
Class Method Details
.banner ⇒ Object
Defines the banner for this CLI generator
11 |
# File 'lib/lazy-head-gen/admin_controller_test.rb', line 11 def self.; "padrino g admin_controller_test [name]"; end |
.source_root ⇒ Object
Define the source template root
9 |
# File 'lib/lazy-head-gen/admin_controller_test.rb', line 9 def self.source_root; File.(File.dirname(__FILE__)); end |
Instance Method Details
#create_admin_controller_test ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/lazy-head-gen/admin_controller_test.rb', line 29 def create_admin_controller_test self.destination_root = [:root] if in_app_root? say "Creating basic admin controller tests for '#{name}'", :green # Set variables @pluralized = name.to_s.tableize @singular = name.to_s.underscore.singularize @controller = @pluralized.camelize @model = @singular.camelize # Check that the admin controller exists controller_path = destination_root("admin", "controllers", "#{@pluralized}.rb") if File.exist?(controller_path) template "templates/admin_controller_test/admin_controller_test.rb.tt", destination_root("test", "admin", "controllers", "#{@pluralized}_controller_test.rb") else say "The controller '#{controller_path} does not exist, please run 'padrino g admin_page #{@model}' to create the initial admin controller", :red return end say "Admin controller tests generation for '#{name}' completed", :green else say "You are not at the root of a Padrino application! (config/boot.rb not found)", :red end end |