Sha256: bf49efdabcc3c5cbbdb25d29a58076fb0599d0e800db8c5d581a85930562a0c2

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

module Keikokuc
  describe NotificationList, '#fetch' do
    it 'finds all notifications for the current user' do
      fake_client = double
      fake_client.should_receive(:get_notifications).
        and_return([user_notifications, nil])
      list = build(:notification_list, client: fake_client)

      result = list.fetch
      expect(result).to be_true

      expect(list.size).to eq(2)
      list.each do |notification|
        expect(user_notifications.map do |h|
          h[:message]
        end).to include(notification.message)
        expect(notification).to be_kind_of(Notification)
      end
    end

    def user_notifications
      [
        {
          resource: 'flying-monkey-123',
          message:  'Database HEROKU_POSTGRESQL_BROWN is over row limits',
          url:      'https://devcenter.heroku.com/how-to-fix-problem',
          severity: 'info'
        },
        {
          resource: 'rising-cloud-42',
          message:  'High OOM rates',
          url:      'https://devcenter.heroku.com/oom',
          severity: 'fatal'
        }
      ]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keikokuc-0.1 spec/keikoku/notification_list_spec.rb