Sha256: 1349b1853be45f448d10914e7ae056f03888454b0069cbab3591146b3197801c

Contents?: true

Size: 700 Bytes

Versions: 7

Compression:

Stored size: 700 Bytes

Contents

module RSpec::Rails
  module Mailer
    def create_mailer name, content=nil
      file = mailer_file_name(name)
      unless File.exist?(file)    
        FileUtils.mkdir_p File.dirname(file)  
        content ||= yield if block_given?
        return if !content          
        File.open(file, 'w') do |f|  
          f.puts content
        end
      end
    end  

    def remove_mailer name
      file = mailer_file_name(name)
      FileUtils.rm_f(file) if File.exist?(file)
    end

    def remove_mailers *names
      names.each{|name| remove_mailer name }
    end      
    
    def mailer_file_name name
      File.join(::Rails.root, "app/mailers/#{name}.rb")
    end        
    
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
generator-spec-0.4.3 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.4.2 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.4.1 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.4.0 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.3.5 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.3.4 lib/rspec_for_generators/rails_helpers/rails_mailer.rb
generator-spec-0.3.3 lib/rspec_for_generators/rails_helpers/rails_mailer.rb