Sha256: 48b0867ffafade2c57a10e86dc19b2345c8be4fcd5fc651028e0774b5551e066

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe StatusNotifierHandler do

  let(:slack_params) do
    {
      enabled: true,
      webhook_url: "https://hooks.slack.com/services/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",
      channel: "#test",
      username: "FaiNow-Test"
    }
  end

  let(:hipchat_params) do
    {
      enabled: true
    }
  end

  context 'without custom message' do
    it 'should run without error' do
      allow_any_instance_of(StatusNotifierHandler).to receive(:send_to_slack).and_return(true)
      allow_any_instance_of(StatusNotifierHandler).to receive(:send_to_hipchat).and_return(true)
      expect{StatusNotifierHandler.new(slack_params, hipchat_params).report}.to_not raise_error
    end
  end

  context 'with custom message' do
    let(:custom_message_params) do
      {
        success_message: '"Success on #{node.name}"',
        failed_message: '"Failed on #{node.name}"'
      }
    end

    it 'should run without error' do
      allow_any_instance_of(StatusNotifierHandler).to receive(:send_to_slack).and_return(true)
      allow_any_instance_of(StatusNotifierHandler).to receive(:send_to_hipchat).and_return(true)
      expect{StatusNotifierHandler.new(slack_params, hipchat_params, custom_message_params).report}.to_not raise_error
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chef-handler-status_notifier-0.5.2 spec/status_notifier_spec.rb
chef-handler-status_notifier-0.5.1 spec/status_notifier_spec.rb
chef-handler-status_notifier-0.5.0 spec/status_notifier_spec.rb