Sha256: 608a1f613ccffa85cc8f649a3b7f1f3594c5aac06f72f77ada71c941cafb4ecd

Contents?: true

Size: 695 Bytes

Versions: 2

Compression:

Stored size: 695 Bytes

Contents

module RSpec::Rails
  module Model  
    include RSpec::Rails::App    
      
    def create_model name, type=nil, &block      
      file = model_file_name(name)
      unless File.exist?(file)    
        FileUtils.mkdir_p File.dirname(file)
        File.open(file, 'w') do |f|  
          f.puts file_content(name, type)
          yield f if block_given?
        end
      end
    end  

    def remove_model name
      file = model_file_name(name)
      FileUtils.rm_f(file) if File.exist?(file)
    end

    def remove_models *names
      names.each{|name| remove_model name }
    end      
    
    def model_file_name name
      File.join(model_dir, "#{name}.rb")
    end        
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
generator-spec-0.4.5 lib/generator_spec/rails_helpers/rails_model.rb
generator-spec-0.4.4 lib/generator_spec/rails_helpers/rails_model.rb