Sha256: 1b73c940d8d204126aa8c5428e041d75c5b1c5c76b451ca31a0fccba31b62f49

Contents?: true

Size: 1.89 KB

Versions: 67

Compression:

Stored size: 1.89 KB

Contents

require 'rails_generator/generators/components/controller/controller_generator'

class RspecControllerGenerator < ControllerGenerator

  def manifest
    record do |m|
      # Check for class naming collisions.
      m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"

      # Controller, helper, views, and spec directories.
      m.directory File.join('app/controllers', class_path)
      m.directory File.join('app/helpers', class_path)
      m.directory File.join('app/views', class_path, file_name)
      m.directory File.join('spec/controllers', class_path)
      m.directory File.join('spec/helpers', class_path)
      m.directory File.join('spec/views', class_path, file_name)

			if Rails::VERSION::STRING < "2.0.0"
        @default_file_extension = "rhtml"
      else
        @default_file_extension = "html.erb"
      end

      # Controller spec, class, and helper.
      m.template 'controller_spec.rb',
        File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")

      m.template 'helper_spec.rb',
        File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")

      m.template 'controller:controller.rb',
        File.join('app/controllers', class_path, "#{file_name}_controller.rb")

      m.template 'controller:helper.rb',
        File.join('app/helpers', class_path, "#{file_name}_helper.rb")

      # Spec and view template for each action.
      actions.each do |action|
        m.template 'view_spec.rb',
          File.join('spec/views', class_path, file_name, "#{action}.#{@default_file_extension}_spec.rb"),
          :assigns => { :action => action, :model => file_name }
        path = File.join('app/views', class_path, file_name, "#{action}.#{@default_file_extension}")
        m.template "controller:view.#{@default_file_extension}",
          path,
          :assigns => { :action => action, :path => path }
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 10 rubygems

Version Path
dchelimsky-rspec-rails-1.1.10 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.1 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.2 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.3 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.4 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.5 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.6 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11.7 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.11 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.12 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.6 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.7 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.8 generators/rspec_controller/rspec_controller_generator.rb
dchelimsky-rspec-rails-1.1.9 generators/rspec_controller/rspec_controller_generator.rb
jcnetdev-rspec-rails-1.1.5 generators/rspec_controller/rspec_controller_generator.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb