Skip to content

Commit

Permalink
Rename mailbox to mailcrate.
Browse files Browse the repository at this point in the history
  • Loading branch information
adscott committed Feb 12, 2012
1 parent c019faf commit 10afc05
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .rvmrc
@@ -1 +1 @@
rvm --create use 1.8.7-p352@mailbox
rvm --create use 1.8.7-p352@mailcrate
File renamed without changes.
6 changes: 3 additions & 3 deletions Rakefile
Expand Up @@ -12,14 +12,14 @@ require 'rubygems/package_task'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.summary = 'A mock SMTP server that can be run and inspected from tests.'
s.name = 'mailbox'
s.name = 'mailcrate'
s.version = '0.0.1'
s.requirements << 'none'
s.require_path = 'lib'
s.files = 'lib/mailbox.rb'
s.files = 'lib/mailcrate.rb'
s.description = 'A mock SMTP server that can be run and inspected from tests. The server runs in memory and received messages can be retrieved.'
s.email = 'adam.d.scott@gmail.com'
s.homepage = 'https://github.com/adscott/mailbox'
s.homepage = 'https://github.com/adscott/mailcrate'
s.authors = 'Adam Scott'
end

Expand Down
16 changes: 8 additions & 8 deletions examples/spec/mailer_spec.rb
@@ -1,5 +1,5 @@
require 'examples/app/mailer'
require 'lib/mailbox'
require 'lib/mailcrate'

ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
Expand All @@ -12,21 +12,21 @@
describe Mailer do

before do
@mailbox = Mailbox.new(2525)
@mailbox.start
@mailcrate = Mailcrate.new(2525)
@mailcrate.start
end

after do
@mailbox.stop
@mailcrate.stop
end

it 'should use Mailbox to send mails' do
it 'should use Mailcrate to send mails' do
mail = Mailer.welcome_email('a@b.com')
mail.deliver

@mailbox.mails[0][:from].should == '<from@example.com>'
@mailbox.mails[0][:to_list].should include '<a@b.com>'
@mailbox.mails[0][:body].should include 'Full of awesomeness.'
@mailcrate.mails[0][:from].should == '<from@example.com>'
@mailcrate.mails[0][:to_list].should include '<a@b.com>'
@mailcrate.mails[0][:body].should include 'Full of awesomeness.'
end

end
6 changes: 3 additions & 3 deletions lib/mailbox.rb → lib/mailcrate.rb
@@ -1,6 +1,6 @@
require 'socket'

class Mailbox
class Mailcrate

attr_reader :mails

Expand Down Expand Up @@ -39,11 +39,11 @@ def get_line
end

def serve( connection )
connection.puts( "220 localhost mailbox ready ESTMP" )
connection.puts( "220 localhost mailcrate ready ESTMP" )
helo = connection.get_line

if helo =~ /^EHLO\s+/
connection.puts "250-localhost mailbox here"
connection.puts "250-localhost mailcrate here"
connection.puts "250 HELP"
end

Expand Down
24 changes: 12 additions & 12 deletions spec/mailbox_spec.rb → spec/mailcrate_spec.rb
@@ -1,28 +1,28 @@
require 'mailbox'
require 'mailcrate'
require 'port'
require 'matchers/eventually'

describe Mailbox do
describe Mailcrate do

before do
@mailbox = Mailbox.new(2525)
@mailcrate = Mailcrate.new(2525)
end

after do
@mailbox.stop
@mailcrate.stop
end

describe 'ports' do

it 'should open a port' do
@mailbox.start
@mailcrate.start

port(2525).should be_open
end

it 'should close a port' do
@mailbox.start
@mailbox.stop
@mailcrate.start
@mailcrate.stop

port(2525).should_not be_open
end
Expand All @@ -33,7 +33,7 @@
describe 'should accept SMTP traffic' do

it 'should recieve email' do
@mailbox.start
@mailcrate.start

socket = TCPSocket.open('localhost', 2525)
socket.puts('helo localhost.localdomain')
Expand All @@ -44,10 +44,10 @@
socket.puts('.')
socket.puts('QUIT')

@mailbox.mails.should eventually have(1).items
@mailbox.mails[0][:from].should == 'myaddress@mydomain.com'
@mailbox.mails[0][:to_list].should include 'somone@somedomain.com'
@mailbox.mails[0][:body].should == 'Hello Fred, can you call me?'
@mailcrate.mails.should eventually have(1).items
@mailcrate.mails[0][:from].should == 'myaddress@mydomain.com'
@mailcrate.mails[0][:to_list].should include 'somone@somedomain.com'
@mailcrate.mails[0][:body].should == 'Hello Fred, can you call me?'
end

end
Expand Down

0 comments on commit 10afc05

Please sign in to comment.