Class: Rspec::Generators::ControllerGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/rspec/controller/controller_generator.rb

Instance Method Summary collapse

Methods inherited from Base

source_root

Instance Method Details

#generate_controller_specObject



12
13
14
15
16
17
# File 'lib/generators/rspec/controller/controller_generator.rb', line 12

def generate_controller_spec
  return unless options[:controller_specs]

  template 'controller_spec.rb',
           File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
end

#generate_view_specsObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/rspec/controller/controller_generator.rb', line 19

def generate_view_specs
  return if actions.empty?
  return unless options[:view_specs]

  empty_directory File.join("spec", "views", file_path)

  actions.each do |action|
    @action = action
    template 'view_spec.rb',
             File.join("spec", "views", file_path, "#{@action}.html.#{options[:template_engine]}_spec.rb")
  end
end