finalize specs
This commit is contained in:
parent
de75db25c4
commit
ee446435e7
|
@ -321,12 +321,47 @@ describe RedStorm::SimpleBolt do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "prepare" do
|
describe "prepare" do
|
||||||
|
it "should assing collector, context, config and call init block" do
|
||||||
|
class BoltPrepare1 < RedStorm::SimpleBolt
|
||||||
|
on_init {trigger}
|
||||||
|
end
|
||||||
|
bolt = BoltPrepare1.new
|
||||||
|
bolt.should_receive(:trigger).once
|
||||||
|
|
||||||
|
bolt.config.should be_nil
|
||||||
|
bolt.context.should be_nil
|
||||||
|
bolt.collector.should be_nil
|
||||||
|
bolt.prepare("config", "context", "collector")
|
||||||
|
bolt.config.should == "config"
|
||||||
|
bolt.context.should == "context"
|
||||||
|
bolt.collector.should == "collector"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "cleanup" do
|
describe "cleanup" do
|
||||||
|
it "should call close block" do
|
||||||
|
class BoltClose1 < RedStorm::SimpleBolt
|
||||||
|
on_close {trigger}
|
||||||
|
end
|
||||||
|
bolt = BoltClose1.new
|
||||||
|
bolt.should_receive(:trigger).once
|
||||||
|
|
||||||
|
bolt.cleanup
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "declare_output_fields" do
|
describe "declare_output_fields" do
|
||||||
|
it "should declare fields" do
|
||||||
|
class BoltDeclare1 < RedStorm::SimpleBolt
|
||||||
|
output_fields :f1, :f2
|
||||||
|
end
|
||||||
|
bolt = BoltDeclare1.new
|
||||||
|
class RedStorm::Fields; end
|
||||||
|
declarer = mock("Declarer")
|
||||||
|
declarer.should_receive(:declare).with("fields")
|
||||||
|
RedStorm::Fields.should_receive(:new).with(["f1", "f2"]).and_return("fields")
|
||||||
|
bolt.declare_output_fields(declarer)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -312,22 +312,80 @@ describe RedStorm::SimpleSpout do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "open" do
|
describe "open" do
|
||||||
|
it "should assing collector, context, config and call init block" do
|
||||||
|
class SpoutPrepare1 < RedStorm::SimpleSpout
|
||||||
|
on_init {trigger}
|
||||||
|
end
|
||||||
|
spout = SpoutPrepare1.new
|
||||||
|
spout.should_receive(:trigger).once
|
||||||
|
|
||||||
|
spout.config.should be_nil
|
||||||
|
spout.context.should be_nil
|
||||||
|
spout.collector.should be_nil
|
||||||
|
spout.open("config", "context", "collector")
|
||||||
|
spout.config.should == "config"
|
||||||
|
spout.context.should == "context"
|
||||||
|
spout.collector.should == "collector"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "close" do
|
describe "close" do
|
||||||
|
it "should call close block" do
|
||||||
|
class SpoutClose1 < RedStorm::SimpleSpout
|
||||||
|
on_close {trigger}
|
||||||
|
end
|
||||||
|
spout = SpoutClose1.new
|
||||||
|
spout.should_receive(:trigger).once
|
||||||
|
|
||||||
|
spout.close
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "declare_output_fields" do
|
describe "declare_output_fields" do
|
||||||
|
it "should declare fields" do
|
||||||
|
class SpoutDeclare1 < RedStorm::SimpleSpout
|
||||||
|
output_fields :f1, :f2
|
||||||
|
end
|
||||||
|
spout = SpoutDeclare1.new
|
||||||
|
class RedStorm::Fields; end
|
||||||
|
declarer = mock("Declarer")
|
||||||
|
declarer.should_receive(:declare).with("fields")
|
||||||
|
RedStorm::Fields.should_receive(:new).with(["f1", "f2"]).and_return("fields")
|
||||||
|
spout.declare_output_fields(declarer)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "is_distributed" do
|
describe "is_distributed" do
|
||||||
|
it "should report is_distributed" do
|
||||||
|
RedStorm::SimpleSpout.is_distributed?.should be_false
|
||||||
|
class SpoutIsDistributed1 < RedStorm::SimpleSpout
|
||||||
|
set :is_distributed => true
|
||||||
|
end
|
||||||
|
spout = SpoutIsDistributed1.new
|
||||||
|
spout.is_distributed.should be_true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "ack" do
|
describe "ack" do
|
||||||
|
it "should call ack block" do
|
||||||
|
class SpoutAck1 < RedStorm::SimpleSpout
|
||||||
|
on_ack {|msg_id| trigger(msg_id)}
|
||||||
|
end
|
||||||
|
spout = SpoutAck1.new
|
||||||
|
spout.should_receive(:trigger).once.with("test")
|
||||||
|
spout.ack("test")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "fail" do
|
describe "fail" do
|
||||||
|
it "should call fail block" do
|
||||||
|
class SpoutFail1 < RedStorm::SimpleSpout
|
||||||
|
on_fail {|msg_id| trigger(msg_id)}
|
||||||
|
end
|
||||||
|
spout = SpoutFail1.new
|
||||||
|
spout.should_receive(:trigger).once.with("test")
|
||||||
|
spout.fail("test")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue