Sha256: 9e49ef71e1cc7f38f88960a7b647dd396baec341608dc5551850fa94d9919aa7

Contents?: true

Size: 1.61 KB

Versions: 108

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

RSpec.describe CanvasSync::JobBatches::Batch::Callback.worker_class do
  describe '#perform' do
    it 'does not do anything if it cannot find the callback class' do
      subject.perform('SampleCallback', 'complete', {}, 'ABCD', 'EFGH')
    end

    it 'does not do anything if event is different from complete or success' do
      expect(SampleCallback).not_to receive(:new)
      subject.perform('SampleCallback', 'ups', {}, 'ABCD', 'EFGH')
    end

    it 'calls on_success if defined' do
      callback_instance = double('SampleCallback', on_success: true)
      expect(SampleCallback).to receive(:new).and_return(callback_instance)
      expect(callback_instance).to receive(:on_success)
        .with(instance_of(CanvasSync::JobBatches::Batch::Status), {})
      subject.perform('SampleCallback', 'success', {}, 'ABCD', 'EFGH')
    end

    it 'calls on_complete if defined' do
      callback_instance = double('SampleCallback')
      expect(SampleCallback).to receive(:new).and_return(callback_instance)
      expect(callback_instance).to receive(:on_complete)
        .with(instance_of(CanvasSync::JobBatches::Batch::Status), {})
      subject.perform('SampleCallback', 'complete', {}, 'ABCD', 'EFGH')
    end

    it 'calls specific callback if defined' do
      callback_instance = double('SampleCallback')
      expect(SampleCallback).to receive(:new).and_return(callback_instance)
      expect(callback_instance).to receive(:sample_method)
        .with(instance_of(CanvasSync::JobBatches::Batch::Status), {})
      subject.perform('SampleCallback#sample_method', 'complete', {}, 'ABCD', 'EFGH')
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
canvas_sync-0.17.36 spec/job_batching/callback_spec.rb
canvas_sync-0.17.35 spec/job_batching/callback_spec.rb
canvas_sync-0.17.34 spec/job_batching/callback_spec.rb
canvas_sync-0.17.33 spec/job_batching/callback_spec.rb
canvas_sync-0.17.32 spec/job_batching/callback_spec.rb
canvas_sync-0.17.31 spec/job_batching/callback_spec.rb
canvas_sync-0.17.30 spec/job_batching/callback_spec.rb
canvas_sync-0.17.29 spec/job_batching/callback_spec.rb
canvas_sync-0.17.28 spec/job_batching/callback_spec.rb
canvas_sync-0.17.27 spec/job_batching/callback_spec.rb
canvas_sync-0.17.27.beta1 spec/job_batching/callback_spec.rb
canvas_sync-0.17.26.beta1 spec/job_batching/callback_spec.rb
canvas_sync-0.17.24 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta8 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta7 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta6 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta5 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta4 spec/job_batching/callback_spec.rb
canvas_sync-0.17.23.beta2 spec/job_batching/callback_spec.rb