Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 740df51514

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

Integration Exercise: Mail Servers


written by: Brent Vatne

Description and usage

Jester is a mail friendly mail daemon that saves a bunch of great stories and jokes and is willing to tell them to anyone who asks. He exists in the ethereal realm of email.


  1. Set up dependencies with bundle install. You will also need sqlite installed if you don't have it already.
  2. Rename config/mail_options.example.rb to config/mail_options.rb
  3. Fill it in with an e-mail account that you'd like Jester to watch
  4. Optionally, populate Jester with a few stories by running rake sample
  5. Start Jester by running ./bin/jester.

Now you can e-mail the address you told him to watch, and use the following commands:

Have him remember a story for you

In the subject line of your e-mail put: a funny story "the time I went helicopter fishing" and use the body of the email to tell him the story. He will remember it and tell it to other people looking to brighten up their day.

Of course, some people were born without a funny bone, and have no desire to read anything funny. Jester thinks that's hilarious, but also feels a duty to entertain, so he likes to remember any other type of story too. For example, maybe you heard an interesting fact hat you think Jester and his friends might like to hear. In the subject line of your email write: an interesting story "why the sky is blue"

Ask Jester to brighten up your day

Great, he can remember jokes that I tell him. What use is a Jester that you tell jokes to, but that doesn't tell any to you? Ask Jester for a story by specifying in the subject tell me something funny or perhaps tell me something interesting. I'm not judging you, Jester might be.

All commands

Here's a grab bag of everything you can do. Keep in mind that wherever you see quotation marks, they are required.

a ____ story 'story name here' - Teaches Jester a story so he can share it with others. Example: a funny story 'This story is really funny isn't it'

tell me something __ - Hear a particular kind of story, such as funny Example: tell me something funny

tell something ___ to __@__.__ - Sends a random story to a friend! Example: tell something funny to

tell me '___' - Jester tells you a specific story from his collection Example: tell me 'What do you call a lazy bear?'

what stories do you know? - Lists all of Jester's stories

help - List all available commands

Add more commands to Jester

A command is called a Request in Jester's world. There are two steps to extending Jester's Request repitoire.

1. Write a new Request class

Unlike an old dog, it's easy to teach him new tricks. The first step is to create a new Request class in lib/jester/requests/, which implements the following interface:

self.handle - returns nil if the message subject is not handled by this request, or an instance of itself if it is handled.

self.description - a text description of how to make the request, and what it does.

execute - performs required actions to carry out the request, returns a Jester::Request::Response object

For example, if we wanted to create a greet command:


module Jester
  module Request
    class Greet
      def self.handle(message)
        if message.subject.match(/hello jester/)

      def self.description
        "hello jester - Jester will greet you"

      def initialize(email)
        @email = email

      def execute => "Well hello world!", :email => @email)

2. Tell the Request handler about it

The second and final step is to make sure the Request handler knows about your Request object. In lib/jester/requests.rb, require your new Request class and add it to the array VALID_REQUESTS.

Something went wrong with that request. Please try again.