Permalink
Browse files

Message content

  • Loading branch information...
1 parent 2f202e9 commit 7cbd2d63089e70deb267a1fe750d3997b75c28da @adscott committed Feb 12, 2012
Showing with 36 additions and 6 deletions.
  1. +2 −2 lib/mailbox.rb
  2. +34 −4 spec/mailbox_spec.rb
View
@@ -80,8 +80,8 @@ def serve( connection )
@mails << {
:from => from.gsub(/MAIL FROM:\s*/, ''),
- # :to_list => to_list.map { |to| to.gsub( /RCPT TO:\s*/, "" ) }
- # :body => lines.join( "\n" )
+ :to_list => to_list.map { |to| to.gsub( /RCPT TO:\s*/, "" ) },
+ :body => lines.join( "\n" )
}
end
View
@@ -47,13 +47,43 @@ def port(port)
socket.puts('.')
socket.puts('QUIT')
- while(@mailbox.mails.empty?) do
- sleep(0.1)
- end
-
+ @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?'
end
end
+end
+
+class Eventually
+ def initialize(delegate)
+ @delegate = delegate
+ end
+
+ def matches?(target)
+ @target = target
+
+ count = 0
+ until(@delegate.matches?(target)) do
+ return false if count >= 10
+ sleep(0.1)
+ count += 1
+ end
+
+ true
+ end
+
+ def failure_message
+ @delegate.failure_message
+ end
+
+ def negative_failure_message
+ @delegate.negative_failure_message
+ end
+end
+
+def eventually(delegate)
+ Eventually.new(delegate)
end

0 comments on commit 7cbd2d6

Please sign in to comment.