Sha256: 6a09fadd8ce21bbdb9a7fe249ffc5950596569ae4eb5aa1de449f212ebc802dd
Contents?: true
Size: 1.14 KB
Versions: 14
Compression:
Stored size: 1.14 KB
Contents
# encoding: utf-8 require "spec_helper" require "amq/client/entity" describe AMQ::Client::Entity do subject do AMQ::Client::Entity.new(Object.new) end it "should maintain an associative array of callbacks" do subject.callbacks.should be_kind_of(Hash) end describe "#exec_callback" do it "executes callback for given event" do proc = Proc.new { |*args, &block| @called = true } expect { subject.define_callback(:init, proc) subject.define_callback :init do @called2 = true end }.to change(subject.callbacks, :size).from(0).to(1) subject.callbacks[:init].size.should == 2 subject.exec_callback(:init) @called.should be_true @called2.should be_true end it "should pass arguments to the callback" do subject.define_callback :init, Proc.new { |*args| args.first } subject.exec_callback(:init, 1).should eql([1]) end it "should pass block to the callback" do subject.define_callback :init, Proc.new { |*args, &block| block.call } subject.exec_callback(:init) { "block" }.should == ["block"] end end end
Version data entries
14 entries across 14 versions & 1 rubygems