Sha256: e1cea8de52b71d48b376be7b6fe7dc2049c511f9e708621b201ce2b3ce484269

Contents?: true

Size: 1.14 KB

Versions: 27

Compression:

Stored size: 1.14 KB

Contents

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

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

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

  describe 'callback' do
    it 'should be invoked with resource' do
      proc = Proc.new { }
      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.new { }
      proc2 = Proc.new { }
      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

27 entries across 27 versions & 1 rubygems

Version Path
acfs-0.42.0 spec/support/shared/find_callbacks.rb
acfs-0.41.1 spec/support/shared/find_callbacks.rb
acfs-0.41.1.beta1 spec/support/shared/find_callbacks.rb
acfs-0.41.0 spec/support/shared/find_callbacks.rb
acfs-0.40.1.rc1 spec/support/shared/find_callbacks.rb
acfs-0.40.0 spec/support/shared/find_callbacks.rb
acfs-0.39.1 spec/support/shared/find_callbacks.rb
acfs-0.39.0 spec/support/shared/find_callbacks.rb
acfs-1.0.0.dev.1.b305 spec/support/shared/find_callbacks.rb
acfs-0.38.0 spec/support/shared/find_callbacks.rb
acfs-1.0.0.dev.1.b298 spec/support/shared/find_callbacks.rb
acfs-1.0.0.dev.1.b297 spec/support/shared/find_callbacks.rb
acfs-0.37.0.1.b295 spec/support/shared/find_callbacks.rb
acfs-0.37.0 spec/support/shared/find_callbacks.rb
acfs-0.36.0.1.b293 spec/support/shared/find_callbacks.rb
acfs-0.36.0 spec/support/shared/find_callbacks.rb
acfs-0.35.0.1.b291 spec/support/shared/find_callbacks.rb
acfs-0.35.0 spec/support/shared/find_callbacks.rb
acfs-0.34.1.1.b289 spec/support/shared/find_callbacks.rb
acfs-0.34.1 spec/support/shared/find_callbacks.rb