Sha256: e2eca6775070089453cc2fa0111428b803650f79ee7fe028a2941b78c5fa9e67
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
# encoding: utf-8 require "spec_helper" require "amq/client/entity" describe AMQ::Client::Entity do let(:klazz) do Class.new do include AMQ::Client::Entity end end subject do klazz.new(Object.new) end it "should maintain an associative array of callbacks" do subject.callbacks.should be_kind_of(Hash) end describe "#has_callback?" do it "should return true if entity has at least one callback with given name" do subject.define_callback(:init, proc {}) subject.has_callback?(:init).should be_true end it "should return false if entity doesn't have callbacks with given name" do subject.has_callback?(:init).should be_false end 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
amq-client-0.7.0.alpha25 | spec/unit/client/entity_spec.rb |
amq-client-0.7.0.alpha24 | spec/unit/client/entity_spec.rb |