Sha256: 747a01b02484d4f96a86826af58115799d65162a0a3ed5de37e52c92303f8a44

Contents?: true

Size: 1.13 KB

Versions: 22

Compression:

Stored size: 1.13 KB

Contents

shared_examples 'a query method with multi-callback support' do
  let(:cb) { Proc.new }

  it 'should invoke callback' do
    expect do |cb|
      action.call cb
      Acfs.run
    end.to yield_with_args
  end

  it 'should invoke multiple callbacks' do
    expect do |cb|
      object = action.call cb
      Acfs.add_callback object, &cb
      Acfs.run
    end.to yield_control.exactly(2).times
  end

  describe 'callback' do
    it 'should be invoked with resource' do
      proc = proc {}
      expect(proc).to receive(:call) do |res|
        expect(res).to equal @object
        expect(res).to be_loaded
      end

      @object = action.call proc
      Acfs.run
    end

    it 'should invoke multiple callback with loaded resource' do
      proc1 = proc {}
      proc2 = proc {}
      expect(proc1).to receive(:call) do |user|
        expect(user).to equal @object
        expect(user).to be_loaded
      end
      expect(proc2).to receive(:call) do |user|
        expect(user).to equal @object
        expect(user).to be_loaded
      end

      @object = action.call proc1
      Acfs.add_callback(@object, &proc2)
      Acfs.run
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
acfs-1.3.2 spec/support/shared/find_callbacks.rb
acfs-1.3.1 spec/support/shared/find_callbacks.rb
acfs-1.3.0 spec/support/shared/find_callbacks.rb
acfs-1.2.1 spec/support/shared/find_callbacks.rb
acfs-0.50.0 spec/support/shared/find_callbacks.rb
acfs-1.2.0 spec/support/shared/find_callbacks.rb
acfs-0.49.1 spec/support/shared/find_callbacks.rb
acfs-1.1.1 spec/support/shared/find_callbacks.rb
acfs-0.49.0 spec/support/shared/find_callbacks.rb
acfs-1.1.0 spec/support/shared/find_callbacks.rb
acfs-0.48.2 spec/support/shared/find_callbacks.rb
acfs-1.0.1 spec/support/shared/find_callbacks.rb
acfs-0.48.1 spec/support/shared/find_callbacks.rb
acfs-1.0.0 spec/support/shared/find_callbacks.rb
acfs-0.48.0 spec/support/shared/find_callbacks.rb
acfs-0.47.0 spec/support/shared/find_callbacks.rb
acfs-0.46.0 spec/support/shared/find_callbacks.rb
acfs-0.45.0 spec/support/shared/find_callbacks.rb
acfs-0.44.0 spec/support/shared/find_callbacks.rb
acfs-0.43.2 spec/support/shared/find_callbacks.rb