Sha256: 2baa6f46290326200cb34c80ab4dd9aba71d36ce2a62cab44abc2ce21a6eb0f3
Contents?: true
Size: 1.63 KB
Versions: 4
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true RSpec.describe TwilioBase::TaskRouter::Worker do include_context :global_config describe '.create' do it 'creates a new worker' do _idle_activity = TwilioBase::Fake::TaskRouter::Activity.new .create(friendly_name: 'Idle') expect { described_class.create(name: 'Name', attributes: {}) } .to change { TwilioBase::Fake::TaskRouter::Worker.workers.count } .by(1) end it 'creates worker with correct attributes' do friendly_name = 'Name' idle_activity = TwilioBase::Fake::TaskRouter::Activity.new .create(friendly_name: 'Idle') described_class.create(name: friendly_name, attributes: {}) new_worker = TwilioBase::Fake::TaskRouter::Worker.workers.last expect(new_worker.friendly_name).to eq friendly_name expect(new_worker.activity_sid).to eq idle_activity.sid end end describe '.find' do it 'returns the relevant worker' do _idle_activity = TwilioBase::Fake::TaskRouter::Activity.new .create(friendly_name: 'Idle') found_worker = TwilioBase::Fake::TaskRouter::Worker.new.create({}) _not_found_worker = TwilioBase::Fake::TaskRouter::Worker.new.create({}) expect(described_class.find(found_worker.sid)).to eq found_worker end context 'non-matching worker' do it 'returns nil' do _idle_activity = TwilioBase::Fake::TaskRouter::Activity.new .create(friendly_name: 'Idle') _not_found_worker = TwilioBase::Fake::TaskRouter::Worker.new.create({}) expect(described_class.find(FactoryBot.generate(:worker_sid))).to be_nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems