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 :controllers, :type => :boolean, :default => true
      class_option :views,       :type => :boolean, :default => true

      hook_for :integration_tool, :as => :integration

      def create_controller_files
        return unless options[:controllers]

        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[:views] 

        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

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 :controllers, :type => :boolean, :default => true
      class_option :views,       :type => :boolean, :default => true

      def create_controller_files
        return unless options[:controllers]

        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[:views] 

        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

Revert "Tell rails' generator to generate rspec request specs when generating a"
Revert "Tell rails' generator to generate rspec request specs when generating a"

This reverts commit 12f0afaa0410504170fad7e5f99c75cffa0cd40d.

- Rails controller generator does not generate the routes needed for the
  generated request spec. Backing this out.
