Sha256: ce7ac9dadcf64c034af744aa809f0c0935715e3bb53b22c2ee5746108bf1a09e

Contents?: true

Size: 1.55 KB

Versions: 11

Compression:

Stored size: 1.55 KB

Contents

require 'spec_helper'
require 'flapjack/gateways/email'

describe Flapjack::Gateways::Email, :logger => true do

  it "sends a mail with text and html parts" do
    email = double('email')

    entity_check = double(Flapjack::Data::EntityCheck)
    redis = double('redis')

    # TODO better checking of what gets passed here
    expect(EM::P::SmtpClient).to receive(:send).with(
      hash_including(:host    => 'localhost',
                     :port    => 25)).and_return(email)

    response = double(response)
    expect(response).to receive(:"respond_to?").with(:code).and_return(true)
    expect(response).to receive(:code).and_return(250)

    expect(EM::Synchrony).to receive(:sync).with(email).and_return(response)

    notification = {'notification_type'   => 'recovery',
                    'contact_first_name'  => 'John',
                    'contact_last_name'   => 'Smith',
                    'state'               => 'ok',
                    'state_duration'      => 2,
                    'summary'             => 'smile',
                    'last_state'          => 'problem',
                    'last_summary'        => 'frown',
                    'time'                => Time.now.to_i,
                    'event_id'            => 'example.com:ping'}

    Flapjack::Gateways::Email.instance_variable_set('@config', {})
    Flapjack::Gateways::Email.instance_variable_set('@redis', redis)
    Flapjack::Gateways::Email.instance_variable_set('@logger', @logger)
    Flapjack::Gateways::Email.start
    Flapjack::Gateways::Email.perform(notification)
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
flapjack-0.8.10 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.9 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.8 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.7 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.6 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.5 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.4 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.3 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.2 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.1 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.8.0 spec/lib/flapjack/gateways/email_spec.rb