factory_girl
https://github.com/thoughtbot/factory_girl
Ruby
A library for setting up Ruby objects as test data.
Mail.new
Allows you to create a new Mail::Message object. You can make an email via passing a string or passing a block. For example, the following two examples will create the same email message: Creating via a string: string = "To: [email protected]\r\n" string << "From: [email protected]\r\n" string << "Subject: This is an email\r\n" string << "\r\n" string << "This is the body" Mail.new(string) Or creating via a block: message = Mail.new do to '[email protected]' from '[email protected]' subject 'This is an email' body 'This is the body' end Or creating via a hash (or hash like object): message = Mail.new({:to => '[email protected]', 'from' => '[email protected]', :subject => 'This is an email', :body => 'This is the body' }) Note, the hash keys can be strings or symbols, the passed in object does not need to be a hash, it just needs to respond to :each_pair and yield each key value pair. As a side note, you can also create a new email through creating a Mail::Message object directly and then passing in values via string, symbol or direct method calls. See Mail::Message for more information. mail = Mail.new mail.to = '[email protected]' mail[:from] = '[email protected]' mail['subject'] = 'This is an email' mail.body = 'This is the body'
Edit
git clone [email protected]:thoughtbot/factory_girl.git
cd factory_girl
open
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Mail-new-for-pr
# Commit to gitgit add git commit -m "better docs for Mail.new"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Mail-new-for-pr
hub pull-request
# Celebrate!