Sha256: 5ae8c25b39912ee4a94fa417ddd7e7b4790cb6d7e710a275bb5126e3eae5d202

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 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
    EM::P::SmtpClient.should_receive(:send).with(
      hash_including(:host    => 'localhost',
                     :port    => 25)).and_return(email)

    response = double(response)
    response.should_receive(:"respond_to?").with(:code).and_return(true)
    response.should_receive(:code).and_return(250)

    EM::Synchrony.should_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

7 entries across 7 versions & 1 rubygems

Version Path
flapjack-0.7.35 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.34 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.33 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.32 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.31 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.30 spec/lib/flapjack/gateways/email_spec.rb
flapjack-0.7.29 spec/lib/flapjack/gateways/email_spec.rb