Sha256: 5fc6bcb4981e6209bbf126f818f0738c40f7c91d78e449fb95086be50a1f2266

Contents?: true

Size: 1011 Bytes

Versions: 12

Compression:

Stored size: 1011 Bytes

Contents

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 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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rspec-rails-2.0.0.beta.9.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.8 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.7 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.6 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.5 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.4 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.3 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.beta.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.a10 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.a9 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.0.0.a8 lib/generators/rspec/controller/controller_generator.rb