Sha256: 100e6fb56d906ff74c81c9d02d8770faa610edd125a1b90b700296e99ec9d519

Contents?: true

Size: 1.5 KB

Versions: 24

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe Rearview::AlertsHandler do
  let(:job) { create(:job,:alert_keys=>["mailto:foo@foo.com","pagerduty:387214d0a12c012fbf5a22000afc49b8"]) }
  let(:email_alert) { mock }
  let(:pager_alert) { mock }
  let(:error_results) {
    {:output=>
      {
        :status=>"error",
        :output=>{:status=>"error", :output=>"initialize: name or service not known", :graph_data=>nil},
        :message=>"initialize: name or service not known", :data=>nil
      }
    }
  }
  context 'run' do
    before do
      Rearview::Alerts::EmailAlert.stubs(:new).returns(email_alert)
      Rearview::Alerts::PagerDutyAlert.stubs(:new).returns(pager_alert)
    end
    it 'should not send alerts if they are disabled' do
      Rearview.config.stubs(:alerts_enabled?).returns(false)
      alerts_handler = Rearview::AlertsHandler.new(job,error_results)
      email_alert.expects(:alert).never
      alerts_handler.run
    end
    it 'should keep sending alerts even if an alert client fails' do
      alerts_handler = Rearview::AlertsHandler.new(job,error_results)
      email_alert.stubs(:alert).raises(StandardError,"oops")
      pager_alert.stubs(:alert).raises(StandardError,"oops")
      expect{ alerts_handler.run }.not_to raise_error
    end
    it 'returns itself' do
      alerts_handler = Rearview::AlertsHandler.new(job,error_results)
      email_alert.expects(:alert).once
      pager_alert.stubs(:alert).raises(StandardError,"unexpected")
      expect(alerts_handler.run).to eq(alerts_handler)
    end
  end

end


Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rearview-1.2.3-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.2.2.rc.2-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.2.2.rc.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.2.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.2.0-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.1.2-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.1.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.1.0-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.3.rc.4-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.3.rc.3-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.3.rc.2-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.3.rc.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.2-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.2.rc.4-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.2.rc.3-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.2.rc.2-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.2.rc.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.1-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.0-jruby spec/lib/rearview/alerts_handler_spec.rb
rearview-1.0.0.rc5-jruby spec/lib/rearview/alerts_handler_spec.rb