Sha256: 104b484e28e1d42cfaa2f89832ef38ec85526887c5d0fcb3b3a69f22624449ba

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require 'chewy_kiqqer'

class Gummi
  include ChewyKiqqer::Mixin

  def self.after_save(*args) ; end
  def self.after_destroy(*args) ; end
  def id ; 17 ; end

end

describe ChewyKiqqer::Mixin do

  context 'class methods' do
    it 'installs the hooks' do
      Gummi.should_receive(:after_save).with(:queue_job)
      Gummi.should_receive(:after_destroy).with(:queue_job)
      Gummi.async_update_index('xxx')
    end

    it 'knows the index_name' do
      Gummi.async_update_index('bar#foo')
      Gummi.index_name.should eq 'bar#foo'
    end
  end

  context '#queue_job' do

    let(:record) { Gummi.new }

    it 'queues the job' do
      Gummi.async_update_index 'foo#bar'
      ChewyKiqqer::Worker.should_receive(:perform_async).with('foo#bar', 17)
      record.queue_job
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chewy_kiqqer-0.0.1 spec/mixin_spec.rb