File: que_spec.rb

package info (click to toggle)
ruby-mail-room 0.10.0%2Breally0.0.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 376 kB
  • sloc: ruby: 1,749; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require 'spec_helper'
require 'mail_room/delivery/que'

describe MailRoom::Delivery::Que do
  describe '#deliver' do
    let(:mailbox) {build_mailbox({
      delivery_options: {
        database: 'delivery_test',
        username: 'postgres',
        password: '',
        queue: 'default',
        priority: 5,
        job_class: 'ParseMailJob'
      }
    })}

    let(:connection) {stub}
    let(:options) {MailRoom::Delivery::Que::Options.new(mailbox)}

    it 'stores the message in que_jobs table' do
      PG.expects(:connect).with({
        host: 'localhost',
        port: 5432,
        dbname: 'delivery_test',
        user: 'postgres',
        password: ''
      }).returns(connection)

      connection.expects(:exec).with(
        "INSERT INTO que_jobs (priority, job_class, queue, args) VALUES ($1, $2, $3, $4)",
        [
          5,
          'ParseMailJob',
          'default',
          JSON.dump(['email'])
        ]
      )

      MailRoom::Delivery::Que.new(options).deliver('email')
    end
  end
end