Sha256: 1d2e4a72d1a8f989094d5a3dd83d68c946a273d591c0e0474125ade1e7af0806

Contents?: true

Size: 1.08 KB

Versions: 43

Compression:

Stored size: 1.08 KB

Contents

require 'generators/rspec'

module Rspec
  module Generators
    # @private
    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

43 entries across 42 versions & 5 rubygems

Version Path
rspec-rails-3.9.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.8.3 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.9.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-4.0.0.beta2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.8.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.8.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.8.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.7.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.7.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.7.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.6.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.6.0 lib/generators/rspec/controller/controller_generator.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/rspec-rails-3.5.2/lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.6.0.beta2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.6.0.beta1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.5.2 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.5.1 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.5.0 lib/generators/rspec/controller/controller_generator.rb
rspec-rails-3.5.0.beta4 lib/generators/rspec/controller/controller_generator.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/rspec-rails-3.4.2/lib/generators/rspec/controller/controller_generator.rb