Sha256: 0c901984a06c30c7b805e30a5e6704ac1f256a97ffaca6c2b1dffe9a72caa025

Contents?: true

Size: 1.04 KB

Versions: 46

Compression:

Stored size: 1.04 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]

        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

46 entries across 41 versions & 5 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-rails-2.13.0/lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.13.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.12.2 lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.12.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.12.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.11.4 lib/generators/rspec/controller/controller_generator.rb
gem_repackager-0.1.0 support/gems/rspec-rails-2.11.0/lib/generators/rspec/controller/controller_generator.rb
rspec-rails-2.11.0 lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/rspec-rails-2.10.1/lib/generators/rspec/controller/controller_generator.rb