astrotrain 0.4.0 → 0.4.1
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.
- data/VERSION +1 -1
 - data/astrotrain.gemspec +1 -1
 - data/lib/astrotrain/message.rb +1 -1
 - data/test/message_test.rb +4 -0
 - data/test/transport_test.rb +41 -39
 - metadata +1 -1
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.4. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.4.1
         
     | 
    
        data/astrotrain.gemspec
    CHANGED
    
    
    
        data/lib/astrotrain/message.rb
    CHANGED
    
    
    
        data/test/message_test.rb
    CHANGED
    
    | 
         @@ -145,6 +145,10 @@ class Astrotrain::MessageTest < Astrotrain::TestCase 
     | 
|
| 
       145 
145 
     | 
    
         
             
                    @message = Astrotrain::Message.parse(@raw)
         
     | 
| 
       146 
146 
     | 
    
         
             
                  end
         
     | 
| 
       147 
147 
     | 
    
         | 
| 
      
 148 
     | 
    
         
            +
                  it "parses message-id" do
         
     | 
| 
      
 149 
     | 
    
         
            +
                    assert_equal 'a16be7390810161014n52b603e9k1aa6bb803c6735aa@mail.gmail.com', @message.message_id
         
     | 
| 
      
 150 
     | 
    
         
            +
                  end
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
       148 
152 
     | 
    
         
             
                  it "parses TMail::Mail headers" do
         
     | 
| 
       149 
153 
     | 
    
         
             
                    expected = {'mime-version' => '1.0', 'content-type' => 'text/plain; charset=ISO-8859-1', 'to' => 'Processor <processor@astrotrain.com>',
         
     | 
| 
       150 
154 
     | 
    
         
             
                      'x-custom' => 'reply', 'content-transfer-encoding' => '7bit', 'content-disposition' => 'inline', 'message-id' => '<a16be7390810161014n52b603e9k1aa6bb803c6735aa@mail.gmail.com>'}
         
     | 
    
        data/test/transport_test.rb
    CHANGED
    
    | 
         @@ -58,53 +58,55 @@ class Astrotrain::TransportTest < Astrotrain::TestCase 
     | 
|
| 
       58 
58 
     | 
    
         
             
                end
         
     | 
| 
       59 
59 
     | 
    
         
             
              end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
               
     | 
| 
       62 
     | 
    
         
            -
                 
     | 
| 
       63 
     | 
    
         
            -
                   
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                before do
         
     | 
| 
       69 
     | 
    
         
            -
                  @trans   = Astrotrain::Mapping::Jabber.new(@message, @mapping, @message.recipients(%w(delivered_to)).first)
         
     | 
| 
       70 
     | 
    
         
            -
                end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                it "sets #content" do
         
     | 
| 
       73 
     | 
    
         
            -
                  expected = "From: %s\nTo: %s\nSubject: %s\nEmails: %s\n%s" % [@message.sender, @message.recipients(%w(delivered_to)).first, @message.subject, @message.recipients(%w(original_to to)) * ", ", @message.body]
         
     | 
| 
       74 
     | 
    
         
            -
                  assert_equal expected, @trans.content
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                it "sets content with mapping separator set" do
         
     | 
| 
       78 
     | 
    
         
            -
                  @message = Astrotrain::Message.parse(mail(:reply))
         
     | 
| 
       79 
     | 
    
         
            -
                  @mapping.separator = "=" * 5
         
     | 
| 
       80 
     | 
    
         
            -
                  @trans   = Astrotrain::Mapping::Jabber.new(@message, @mapping, @message.recipients(%w(delivered_to)).first)
         
     | 
| 
       81 
     | 
    
         
            -
                  expected = "From: %s\nTo: %s\nSubject: %s\nEmails: %s\n%s" % [@message.sender, @message.recipients(%w(delivered_to)).first, @message.subject, '', "blah blah"]
         
     | 
| 
       82 
     | 
    
         
            -
                  assert_equal expected, @trans.content
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                describe "when processing" do
         
     | 
| 
       86 
     | 
    
         
            -
                  before do
         
     | 
| 
       87 
     | 
    
         
            -
                    @conn = Object.new
         
     | 
| 
       88 
     | 
    
         
            -
                    stub(@trans).connection { @conn }
         
     | 
| 
       89 
     | 
    
         
            -
                    stub(Astrotrain::Mapping::Jabber).new { @trans }
         
     | 
| 
      
 61 
     | 
    
         
            +
              if Astrotrain::Mapping.const_defined?(:Jabber)
         
     | 
| 
      
 62 
     | 
    
         
            +
                describe "jabber" do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  before :all do
         
     | 
| 
      
 64 
     | 
    
         
            +
                    @dest    = 'foo@bar.com'
         
     | 
| 
      
 65 
     | 
    
         
            +
                    @message = Astrotrain::Message.parse(mail(:custom))
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @mapping = Astrotrain::Mapping.new(:destination => @dest, :transport => 'jabber')
         
     | 
| 
       90 
67 
     | 
    
         
             
                  end
         
     | 
| 
       91 
68 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                   
     | 
| 
       93 
     | 
    
         
            -
                     
     | 
| 
       94 
     | 
    
         
            -
                    @trans.process
         
     | 
| 
      
 69 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 70 
     | 
    
         
            +
                    @trans   = Astrotrain::Mapping::Jabber.new(@message, @mapping, @message.recipients(%w(delivered_to)).first)
         
     | 
| 
       95 
71 
     | 
    
         
             
                  end
         
     | 
| 
       96 
72 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
                  it " 
     | 
| 
       98 
     | 
    
         
            -
                     
     | 
| 
       99 
     | 
    
         
            -
                     
     | 
| 
      
 73 
     | 
    
         
            +
                  it "sets #content" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                    expected = "From: %s\nTo: %s\nSubject: %s\nEmails: %s\n%s" % [@message.sender, @message.recipients(%w(delivered_to)).first, @message.subject, @message.recipients(%w(original_to to)) * ", ", @message.body]
         
     | 
| 
      
 75 
     | 
    
         
            +
                    assert_equal expected, @trans.content
         
     | 
| 
       100 
76 
     | 
    
         
             
                  end
         
     | 
| 
       101 
77 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
                   
     | 
| 
       103 
     | 
    
         
            -
                    Astrotrain:: 
     | 
| 
      
 78 
     | 
    
         
            +
                  it "sets content with mapping separator set" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                    @message = Astrotrain::Message.parse(mail(:reply))
         
     | 
| 
      
 80 
     | 
    
         
            +
                    @mapping.separator = "=" * 5
         
     | 
| 
      
 81 
     | 
    
         
            +
                    @trans   = Astrotrain::Mapping::Jabber.new(@message, @mapping, @message.recipients(%w(delivered_to)).first)
         
     | 
| 
      
 82 
     | 
    
         
            +
                    expected = "From: %s\nTo: %s\nSubject: %s\nEmails: %s\n%s" % [@message.sender, @message.recipients(%w(delivered_to)).first, @message.subject, '', "blah blah"]
         
     | 
| 
      
 83 
     | 
    
         
            +
                    assert_equal expected, @trans.content
         
     | 
| 
       104 
84 
     | 
    
         
             
                  end
         
     | 
| 
       105 
85 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
                   
     | 
| 
       107 
     | 
    
         
            -
                     
     | 
| 
      
 86 
     | 
    
         
            +
                  describe "when processing" do
         
     | 
| 
      
 87 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 88 
     | 
    
         
            +
                      @conn = Object.new
         
     | 
| 
      
 89 
     | 
    
         
            +
                      stub(@trans).connection { @conn }
         
     | 
| 
      
 90 
     | 
    
         
            +
                      stub(Astrotrain::Mapping::Jabber).new { @trans }
         
     | 
| 
      
 91 
     | 
    
         
            +
                    end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                    it "makes jabber delivery" do
         
     | 
| 
      
 94 
     | 
    
         
            +
                      mock(@conn).deliver(@mapping.destination, @trans.content)
         
     | 
| 
      
 95 
     | 
    
         
            +
                      @trans.process
         
     | 
| 
      
 96 
     | 
    
         
            +
                    end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                    it "makes jabber delivery from Transport" do
         
     | 
| 
      
 99 
     | 
    
         
            +
                      mock(@conn).deliver(@mapping.destination, @trans.content)
         
     | 
| 
      
 100 
     | 
    
         
            +
                      Astrotrain::Mapping::Transport.process(@message, @mapping, @message.recipients(%w(delivered_to)).first)
         
     | 
| 
      
 101 
     | 
    
         
            +
                    end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                    before :all do
         
     | 
| 
      
 104 
     | 
    
         
            +
                      Astrotrain::Mapping::Transport.processing = true
         
     | 
| 
      
 105 
     | 
    
         
            +
                    end
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                    after :all do
         
     | 
| 
      
 108 
     | 
    
         
            +
                      Astrotrain::Mapping::Transport.processing = false
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
       108 
110 
     | 
    
         
             
                  end
         
     | 
| 
       109 
111 
     | 
    
         
             
                end
         
     | 
| 
       110 
112 
     | 
    
         
             
              end
         
     |