Sha256: 3778570a333bee31097e6f02b8d508a97f12f939cc3b9444e9361cd285ea0469

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

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

      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

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

        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

15 entries across 15 versions & 2 rubygems

Version Path
rspec-rails-2.99.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.0.0.rc1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.99.0.rc1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.14.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.0.0.beta2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.99.0.beta2 lib/generators/rspec/controller/controller_generator.rb
simple_token_authentication-1.0.0.pre.5 test/dummy/lib/generators/rspec/controller/controller_generator.rb
simple_token_authentication-1.0.0.beta.5 test/dummy/lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.14.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.0.0.beta1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.99.0.beta1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.14.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.14.0.rc1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.13.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.13.1 lib/generators/rspec/controller/controller_generator.rb