Class: Rys::Generators::Rspec::ControllerGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/generators/rys/rspec/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/rys/rspec/controller_generator.rb', line 12

def generate_controller_spec
  return unless options[:controller_specs]

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

#generate_view_specsObject


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/rys/rspec/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
    target_file = File.join('spec/views', file_path, "#{action}.html.erb_spec.rb")
    template 'view_spec.rb', target_file
  end
end