Module: RSpec::Rails::Mailer
- Defined in:
- lib/rspec_for_generators/rails_helpers/rails_mailer.rb
Instance Method Summary collapse
- #create_mailer(name, content) ⇒ Object
- #mailer_file_name(name) ⇒ Object
- #remove_mailer(name) ⇒ Object
- #remove_mailers(*names) ⇒ Object
Instance Method Details
#create_mailer(name, content) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 4 def create_mailer name, content file = mailer_file_name(name) unless File.exist?(file) FileUtils.mkdir_p File.dirname(file) File.open(file, 'w') do |f| f.puts content end end end |
#mailer_file_name(name) ⇒ Object
23 24 25 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 23 def mailer_file_name name File.join(::Rails.root, "app/mailers/#{name}.rb") end |
#remove_mailer(name) ⇒ Object
14 15 16 17 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 14 def remove_mailer name file = mailer_file_name(name) FileUtils.rm_f(file) if File.exist?(file) end |
#remove_mailers(*names) ⇒ Object
19 20 21 |
# File 'lib/rspec_for_generators/rails_helpers/rails_mailer.rb', line 19 def remove_mailers *names names.each{|name| remove_mailer name } end |