bounce_fetcher 0.0.5 → 0.0.6

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.
@@ -22,5 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'tmail', '~> 1.2'
23
23
  s.add_dependency 'bounce-email', '~> 0.0.1'
24
24
 
25
+ s.add_development_dependency 'minitest'
25
26
  s.add_development_dependency 'eventmachine'
26
27
  end
@@ -19,13 +19,15 @@ module BounceFetcher
19
19
  @detector = detector
20
20
  end
21
21
 
22
- def each
22
+ def each(options = {})
23
+ options = { :delete => true }.merge(options)
24
+
23
25
  @fetcher.each do |e|
24
26
  if @detector.permanent_bounce?(e)
25
27
  @extractor.extract_emails(e.body).each do |email|
26
28
  yield email
27
29
  end
28
- e.delete
30
+ e.delete if options[:delete]
29
31
  end
30
32
  end
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module BounceFetcher
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -35,22 +35,36 @@ class TestBounceFetcher < MiniTest::Unit::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ def setup
39
+ @permanent_bounce = Email.new('foo@bar.com', true)
40
+ @temporary_bounce = Email.new('bar@baz.com', false)
41
+ @pop_fetcher = FakePopFetcher.new(@permanent_bounce, @temporary_bounce)
42
+ @extractor = FakeExtractor.new
43
+ @detector = FakeBounceDetector.new
44
+ @fetcher = BounceFetcher.new(@pop_fetcher, @extractor, @detector)
45
+ end
46
+
38
47
  def test_each_only_returns_emails_for_permanent_bounces
39
- permanent_bounce = Email.new('foo@bar.com', true)
40
- temporary_bounce = Email.new('bar@baz.com', false)
41
- pop_fetcher = FakePopFetcher.new(permanent_bounce, temporary_bounce)
42
- extractor = FakeExtractor.new
43
- detector = FakeBounceDetector.new
44
- fetcher = BounceFetcher.new(pop_fetcher, extractor, detector)
48
+ emails = []
49
+ @fetcher.each do |email|
50
+ emails << email
51
+ end
45
52
 
53
+ assert_equal ['foo@bar.com'], emails
54
+ assert @permanent_bounce.deleted?
55
+ assert !@temporary_bounce.deleted?
56
+ end
57
+
58
+ def test_each_with_no_delete_option
46
59
  emails = []
47
- fetcher.each do |email|
60
+
61
+ @fetcher.each(:delete => false) do |email|
48
62
  emails << email
49
63
  end
50
64
 
51
65
  assert_equal ['foo@bar.com'], emails
52
- assert permanent_bounce.deleted?
53
- assert !temporary_bounce.deleted?
66
+ assert !@permanent_bounce.deleted?
67
+ assert !@temporary_bounce.deleted?
54
68
  end
55
69
 
56
70
  end
@@ -5,12 +5,12 @@ require 'net/smtp'
5
5
  class TestIntegration < MiniTest::Unit::TestCase
6
6
 
7
7
  def start_server
8
- child_pid = fork do
8
+ fork do
9
9
  STDIN.reopen('/dev/null')
10
10
  STDOUT.reopen('/dev/null', 'a')
11
11
  STDERR.reopen(STDOUT)
12
12
  Dir.chdir(File.dirname(__FILE__) + "/support/localpost")
13
- system("ruby -I. localpost.rb")
13
+ exec("ruby -I. localpost.rb")
14
14
  end
15
15
  end
16
16
 
@@ -19,8 +19,8 @@ class TestIntegration < MiniTest::Unit::TestCase
19
19
 
20
20
  mail.to = options[:to] || 'blah@blah.com'
21
21
  mail.from = options[:from] || 'postmaster@blah.com'
22
- mail.subject = options[:subject] || 'mail delivery failed'
23
- mail.body = options[:body] || 'foo@bar.com mailbox unavailable'
22
+ mail.subject = options[:subject] || 'subject'
23
+ mail.body = options[:body] || 'body'
24
24
  mail.date = options[:date] || Time.now
25
25
 
26
26
  begin
@@ -33,10 +33,19 @@ class TestIntegration < MiniTest::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
+ def send_permanent_bounce(options = {})
37
+ options = {
38
+ :subject => 'mail delivery failed',
39
+ :body => 'foo@bar.com mailbox unavailable',
40
+ }.merge(options)
41
+
42
+ send_email(options)
43
+ end
44
+
36
45
  def setup
37
46
  start_server
38
- send_email # bounce
39
- send_email(:subject => 'hi', :body => 'there') # not bounce
47
+ send_permanent_bounce
48
+ send_email
40
49
  end
41
50
 
42
51
  def test_bounce_fetcher
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bounce_fetcher
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease:
4
+ hash: 19
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guterl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-07 00:00:00 -04:00
18
+ date: 2011-04-20 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: eventmachine
53
+ name: minitest
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
@@ -63,6 +63,20 @@ dependencies:
63
63
  version: "0"
64
64
  type: :development
65
65
  version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: eventmachine
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ type: :development
79
+ version_requirements: *id004
66
80
  description: A set of tools for processing email bounces in a flexible way.
67
81
  email:
68
82
  - michael@diminishing.org
@@ -118,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
132
  requirements: []
119
133
 
120
134
  rubyforge_project: bounce_fetcher
121
- rubygems_version: 1.5.2
135
+ rubygems_version: 1.3.7
122
136
  signing_key:
123
137
  specification_version: 3
124
138
  summary: A set of tools for processing email bounces in a flexible way.