Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4321f814ab
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (26 sloc) 1.064 kB
require 'generators/rspec'
module Rspec
module Generators
class ControllerGenerator < Base
argument :actions, :type => :array, :default => [], :banner => "action action"
class_option :template_engine, :desc => "Template engine to generate view files"
class_option :controller_specs, :type => :boolean, :default => true
class_option :view_specs, :type => :boolean, :default => true
def create_controller_files
return unless options[:controller_specs]
template 'controller_spec.rb',
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
end
def create_view_files
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
end
end
end
Jump to Line
Something went wrong with that request. Please try again.