Sha256: 64324b1da06db4da89fea66e3e49c83c246eae92d2e5d56a00e94f01055053a5

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'generators/factory_girl'

module FactoryGirl
  module Generators
    class ModelGenerator < Base
      argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
      class_option :dir, :type => :string, :default => "test/factories", :desc => "The directory where the factories should go"
      
      def create_fixture_file
        version = nil
        begin
          require 'factory_girl/version'
          version = FactoryGirl::VERSION.to_i
        rescue LoadError
          require 'factory_girl'
          version = Factory::VERSION.to_i
        rescue Object => e
          raise "Please install Factory_girl or add it to your Gemfile"
        end
        
        template "fixtures.#{version}.rb", File.join(options[:dir], "#{table_name}.rb")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails3-generators-0.17.4 lib/generators/factory_girl/model/model_generator.rb