Module: RSpec::Rails::Mailer
- Defined in:
- lib/rspec_for_generators/rails_helpers/rails_mailer.rb
Instance Method Summary collapse
- #create_mailer(name, content = nil) ⇒ Object
- #mailer_file_name(name) ⇒ Object
- #remove_mailer(name) ⇒ Object
- #remove_mailers(*names) ⇒ Object
Instance Method Details
#create_mailer(name, content = nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 3 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 |
#mailer_file_name(name) ⇒ Object
24 25 26 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 24 def mailer_file_name name File.join(::Rails.root, "app/mailers/#{name}.rb") end |
#remove_mailer(name) ⇒ Object
15 16 17 18 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 15 def remove_mailer name file = mailer_file_name(name) FileUtils.rm_f(file) if File.exist?(file) end |
#remove_mailers(*names) ⇒ Object
20 21 22 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 20 def remove_mailers *names names.each{|name| remove_mailer name } end |