mail_sandbox 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1db70c40876256af6066292100a7f79d93b5299c
4
- data.tar.gz: 6de340966ca78108d6f66ee223a4d8aa2f65f9df
3
+ metadata.gz: ef6649dc80fe7dcd6423161ccf0a0da3e627ea3b
4
+ data.tar.gz: 147f787b4e8a434b28aec93ebb5e5892c8808690
5
5
  SHA512:
6
- metadata.gz: bf680396c02362a1b803d2899e0419834d710d74210628bbcdc3f3bada1b8b0f7e7ac3a2e3cd9eda8e4c0dea869749fd3acc711d1ec8976e1eff4db8cbfd079b
7
- data.tar.gz: f5cfdec2726cfa6cdf2f238d0d4798007eb768051ed68f3ac61d964a344deddca8a35df81279d85fd385185110772b444caae4f11542cdd8f95997029892a904
6
+ metadata.gz: d889269dc9a2240f33293c1c607b44275c9bd381e2d32ddf9242b566fd92239e290a6c16e260e2bcb9a74ccaa8c50937d6905dbbd7fbab982b57f735c84b3387
7
+ data.tar.gz: a1daeb78f6b0096a9fd04e12844568c99dabc1cc481262df70f561eaa5966127a52a6eab733762eaa905c5db85aed08a568db1ef19fe848558553823bf2c47d3
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Rakefile CHANGED
@@ -1,13 +1,2 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require 'rake/testtask'
4
-
5
- task :default => :test
6
- Rake::TestTask.new do |t|
7
- t.libs << "test"
8
- t.test_files = FileList['test/lib/**/*_test.rb']
9
- t.verbose = true
10
- end
11
-
12
- desc "Run tests"
13
- task :default => :test
@@ -2,31 +2,26 @@ require 'json'
2
2
 
3
3
  module MailSandbox
4
4
  class Message
5
-
6
- attr_accessor :data, :recipient, :sender, :completed_at,
7
- :user,
8
- :password
9
-
5
+ attr_accessor :data, :recipients, :sender, :completed_at, :user, :password
10
6
 
11
7
  def initialize
12
8
  @data = []
9
+ @recipients = []
13
10
  end
14
11
 
15
12
  def to_json
16
- to_a.to_json
13
+ to_hash.to_json
17
14
  end
18
15
 
19
-
20
- def to_a
16
+ def to_hash
21
17
  {
22
18
  :password => password,
23
19
  :user => user,
24
- :recipient => recipient,
20
+ :recipients => recipients.join(','),
25
21
  :sender => sender,
26
22
  :completed_at => completed_at,
27
23
  :data => data.join("\r\n"),
28
24
  }
29
25
  end
30
-
31
26
  end
32
27
  end
@@ -9,7 +9,7 @@ module MailSandbox
9
9
  end
10
10
 
11
11
  def update(message)
12
- body = {:message => message.to_a}
12
+ body = {:message => message.to_hash}
13
13
 
14
14
  MailSandbox.logger.debug "Observer::Http send to #{@url} method #{@method} body #{body.to_s}"
15
15
 
@@ -14,7 +14,7 @@ module MailSandbox
14
14
  end
15
15
 
16
16
  def receive_recipient(recipient)
17
- message.recipient = recipient
17
+ message.recipients << recipient
18
18
  true
19
19
  end
20
20
 
@@ -1,3 +1,3 @@
1
1
  module MailSandbox
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -0,0 +1,29 @@
1
+ require "test_helper"
2
+
3
+ class EmServerTest < MiniTest::Unit::TestCase
4
+ def setup
5
+ @em_host = 'localhost'
6
+ @em_port = 2525
7
+ end
8
+
9
+ def test_multiple_recipients
10
+ c = nil
11
+ EM.run {
12
+ EM.start_server(@em_host, @em_port, MailSandbox::Server) { |conn| c = conn }
13
+
14
+ EM::Timer.new(5) { EM.stop }
15
+
16
+ EM::Protocols::SmtpClient.send ({
17
+ host: @em_host,
18
+ port: @em_port,
19
+ domain: "example.com",
20
+ from: "me@example.com",
21
+ to: ["you@example.com", "we@example.com"],
22
+ header: {"Subject"=>"Email subject line", "Reply-to"=>"me@example.com"},
23
+ body: "Not much of interest here."
24
+ })
25
+ }
26
+
27
+ assert_equal( c.message.recipients, ["<you@example.com>", "<we@example.com>"] )
28
+ end
29
+ end
@@ -53,8 +53,4 @@ class ServerTest < MiniTest::Unit::TestCase
53
53
 
54
54
  assert alive?
55
55
  end
56
-
57
-
58
-
59
-
60
56
  end
data/test/test_helper.rb CHANGED
@@ -6,7 +6,9 @@ require 'em-http-request'
6
6
  require "socket"
7
7
  require 'support/my_observer'
8
8
  require 'net/smtp'
9
- require 'mocha'
9
+
10
+ require "minitest/unit"
11
+ require "mocha/mini_test"
10
12
 
11
13
  module SpawnHelper
12
14
  PID_FILE = "/tmp/mail_sandbox.#{rand*1000.to_i}.pid"
@@ -23,7 +23,7 @@ class SubscribeTest < MiniTest::Unit::TestCase
23
23
 
24
24
  def test_http_observer
25
25
  url = "http://localhost/api"
26
- body = {:body => {:message => @message.to_a}}
26
+ body = {:body => {:message => @message.to_hash}}
27
27
 
28
28
  http_mock = mock()
29
29
  http_mock.stubs(:callback)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mail_sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaize
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -166,6 +166,7 @@ files:
166
166
  - test/fixtures/http_response.txt
167
167
  - test/fixtures/message.txt
168
168
  - test/integration/daemonize_test.rb
169
+ - test/integration/em_server_test.rb
169
170
  - test/integration/pidfile_test.rb
170
171
  - test/integration/spawn_test.rb
171
172
  - test/support/config.yml
@@ -192,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
193
  version: '0'
193
194
  requirements: []
194
195
  rubyforge_project:
195
- rubygems_version: 2.1.11
196
+ rubygems_version: 2.1.10
196
197
  signing_key:
197
198
  specification_version: 4
198
199
  summary: SMTP server sandbox
@@ -200,6 +201,7 @@ test_files:
200
201
  - test/fixtures/http_response.txt
201
202
  - test/fixtures/message.txt
202
203
  - test/integration/daemonize_test.rb
204
+ - test/integration/em_server_test.rb
203
205
  - test/integration/pidfile_test.rb
204
206
  - test/integration/spawn_test.rb
205
207
  - test/support/config.yml
@@ -207,4 +209,3 @@ test_files:
207
209
  - test/test_helper.rb
208
210
  - test/unit/config_test.rb
209
211
  - test/unit/subscribe_test.rb
210
- has_rdoc: