Class: Rspec::Generators::ScaffoldGenerator Private
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Base ,
Rails::Generators::NamedBase
|
|
Instance Chain:
self,
Rails::Generators::ResourceHelpers,
Base ,
::RSpec::Rails::FeatureCheck ,
Rails::Generators::NamedBase
|
|
Inherits: |
Rspec::Generators::Base
|
Defined in: | rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb |
Class Method Summary
- .new(*args, &blk) ⇒ ScaffoldGenerator constructor Internal use only
Base
- Inherited
.configuration | Load configuration from |
.source_root |
Instance Attribute Summary
- #generator_args readonly protected Internal use only
Instance Method Summary
- #generate_controller_spec Internal use only
- #generate_request_spec Internal use only
- #generate_routing_spec Internal use only
- #generate_view_specs Internal use only
- #banner protected Internal use only
- #copy_view(view) protected Internal use only
-
#ns_file_name
protected
Internal use only
support for namespaced-resources.
- #ns_parts protected Internal use only
- #ns_prefix protected Internal use only
- #ns_suffix protected Internal use only
-
#ns_table_name
protected
Internal use only
support for namespaced-resources.
- #raw_value_for(attribute) protected Internal use only
- #show_helper(resource_name = file_name) protected Internal use only
- #template_file(folder:, suffix: '') protected Internal use only
- #value_for(attribute) protected Internal use only
Base
- Inherited
::RSpec::Rails::FeatureCheck
- Included
Instance Attribute Details
#generator_args (readonly, protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 71
attr_reader :generator_args
Instance Method Details
#banner (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 127
def self.class. end
#copy_view(view) (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 73
def copy_view(view) template "#{view}_spec.rb", target_path("views", controller_file_path, "#{view}.html.#{ [:template_engine]}_spec.rb") end
#generate_controller_spec
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 28
def generate_controller_spec return unless [:controller_specs] if [:api] template 'api_controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller') else template 'controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller') end end
#generate_request_spec
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 38
def generate_request_spec return unless [:request_specs] if [:api] template 'api_request_spec.rb', template_file(folder: 'requests') else template 'request_spec.rb', template_file(folder: 'requests') end end
#generate_routing_spec
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 58
def generate_routing_spec return unless [:routing_specs] template_file = target_path( 'routing', controller_class_path, "#{controller_file_name}_routing_spec.rb" ) template 'routing_spec.rb', template_file end
#generate_view_specs
[ GitHub ]#ns_file_name (protected)
support for namespaced-resources
#ns_parts (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 92
def ns_parts @ns_parts ||= begin parts = generator_args[0].split(/\/|::/) parts.size > 1 ? parts : [] end end
#ns_prefix (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 99
def ns_prefix @ns_prefix ||= ns_parts[0..-2] end
#ns_suffix (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 103
def ns_suffix @ns_suffix ||= ns_parts[-1] end
#ns_table_name (protected)
support for namespaced-resources
#raw_value_for(attribute) (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 111
def raw_value_for(attribute) case attribute.type when :string attribute.name.titleize when :integer, :float @attribute_id_map ||= {} @attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next + attribute.default else attribute.default end end
#show_helper(resource_name = file_name) (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 131
def show_helper(resource_name = file_name) "#{singular_route_name}_url(#{resource_name})" end
#template_file(folder:, suffix: '') (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 123
def template_file(folder:, suffix: '') target_path(folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb") end
#value_for(attribute) (protected)
[ GitHub ]# File 'rspec-rails/lib/generators/rspec/scaffold/scaffold_generator.rb', line 107
def value_for(attribute) raw_value_for(attribute).inspect end