Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (38 sloc) 985 Bytes
require 'jester'
require 'rspec'
DataMapper.setup(:default, "sqlite::memory:")
RSpec.configure do |config|
config.mock_with :rspec
config.before(:each) { DataMapper.auto_migrate! }
end
def full_path_for(file)
File.join(File.dirname(__FILE__), file)
end
module MailTestHelpers
def emails
[ Mail.read(full_path_for('/sample_data/generic_message.eml')) ]
end
def email(params)
Mail.new do |m|
m.to params[:to] || "to@example.com"
m.from params[:from] || "to@example.com"
m.subject params[:subject] || "subject"
m.body params[:subject] || "body"
end
end
def read_email(filename)
Mail.read(full_path_for("/sample_data/#{filename}.eml"))
end
def fake_server(array)
FakeMailServer.new(array)
end
class FakeMailServer
def initialize(mail_array)
@unread_messages = mail_array
end
def unread_messages
@unread_messages
end
def deliver_message(message); end
end
end