Thinking on hiring me?

Please read

Fernando Guillén

a Freelance Web Developer

cabecera decorativa

software development as an artistic expression

Ruby: FibberMailman, mocking the Net::POP3.start

 

 

 

Fibber MailmanLately I’m involved on projects that do a very intensive use of email accounts as input of information.

The use of mail in an automatic process is always a pain in the ass because of the huge casuistic and also for the difficulty to test it.

Nothing we can do with the first problem but for the second one here is my propose of a very simple Ruby Gem to mock the Net::POP3.start petition so you can simulate the emails that a real POP3 petition could find:

FibberMailman the mock for the Net::POP3.start.

Just charge a bunch of raw mails in an strings array and send them to the FibberMailman.lie_to_me method like this:

require 'fibber_mailman'
 
raw_mails = [
  File.read( "/fixtures/mail1.raw_mail" ) ),
  File.read( "/fixtures/mail2.raw_mail" ) ),
]
 
FibberMailman.lie_to_me( raw_mails ) do
  <your code that uses the Net::POP3.start on any point>
end

Every petition to the Net::POP3.start method into the inside block will be feed with fake emails built from the raw mail strings.

 

One Comment to “Ruby: FibberMailman, mocking the Net::POP3.start”
  1. OldChangKee Says:

    […]The information mentioned in the article are some of the best available […]……

    […]The information mentioned in the article are some of the greatest available […]……

Leave a comment

a Freelance Web Developer is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

Creative Commons License
Fernando Guillen's blog by Fernando Guillen is licensed under a Creative Commons Attribution-NoDerivs 3.0 Unported License.