Class: RspecModelGenerator

Inherits:
ModelGenerator
  • Object
show all
Defined in:
lib/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb

Instance Method Summary collapse

Instance Method Details

#manifestObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vendor/plugins/rspec-rails/generators/rspec_model/rspec_model_generator.rb', line 6

def manifest

  record do |m|
    # Check for class naming collisions.
    m.class_collisions class_path, class_name

    # Model, spec, and fixture directories.
    m.directory File.join('app/models', class_path)
    m.directory File.join('spec/models', class_path)
    unless options[:skip_fixture]
      m.directory File.join('spec/fixtures', class_path)
    end

    # Model class, spec and fixtures.
    m.template 'model:model.rb',      File.join('app/models', class_path, "#{file_name}.rb")
    m.template 'model_spec.rb',       File.join('spec/models', class_path, "#{file_name}_spec.rb")
    unless options[:skip_fixture]
      m.template 'model:fixtures.yml',  File.join('spec/fixtures', "#{table_name}.yml")
    end

    unless options[:skip_migration]
      m.migration_template 'model:migration.rb', 'db/migrate', :assigns => {
        :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
      }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
    end

  end
end