Sha256: 3184d5a194b7431b76b5d87ecfd3fb786e7e3711b7820c424a3d45e90dd37d0d

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require 'mail_room/delivery/que'

describe MailRoom::Delivery::Que do
  describe '#deliver' do
    let(:mailbox) {MailRoom::Mailbox.new({
      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.stubs(:connect).returns(connection)
      connection.stubs(:exec)

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

      expect(PG).to have_received(:connect).with({
        host: 'localhost',
        port: 5432,
        dbname: 'delivery_test',
        user: 'postgres',
        password: ''
      })

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mail_room-0.9.1 spec/lib/delivery/que_spec.rb
mail_room-0.9.0 spec/lib/delivery/que_spec.rb
mail_room-0.8.1 spec/lib/delivery/que_spec.rb
mail_room-0.8.0 spec/lib/delivery/que_spec.rb
mail_room-0.7.0 spec/lib/delivery/que_spec.rb
mail_room-0.6.1 spec/lib/delivery/que_spec.rb
mail_room-0.6.0 spec/lib/delivery/que_spec.rb
mail_room-0.5.2 spec/lib/delivery/que_spec.rb
mail_room-0.5.1 spec/lib/delivery/que_spec.rb
mail_room-0.5.0 spec/lib/delivery/que_spec.rb