spec/eotb_spec.rb in eotb-0.5.2 vs spec/eotb_spec.rb in eotb-0.5.3

- old
+ new

@@ -1,37 +1,48 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Eotb do + it "should log errors" do + logger = mock(Logger) + logger.stub(:new) { logger } + logger.stub(:error) { @response } + Eotb.register_event(:actor, :action, {:username => "John"}).should == @response + end + describe "shoud format objects" do + before do + @@counter = 0 + end it "should format actor in string" do - Eotb.hash_format("actor", :actor).should == {"event[actor]" => "actor"} + Eotb.hash_format("actor", :actor).should == {"event0[actor]" => "actor"} end it "should format actor in hash" do - Eotb.hash_format({:type => "User"}, :actor).should == {"event[actor][type]" => "User"} + Eotb.hash_format({:type => "User"}, :actor).should == {"event0[actor][type]" => "User"} end it "should format actor in nested hash" do - Eotb.hash_format({:type => { :account => "User"}}, :actor).should == {"event[actor][type][account]" => "User"} + Eotb.hash_format({:type => { :account => "User"}}, :actor).should == {"event0[actor][type][account]" => "User"} end end describe "should register data" do before(:each) do @response = "200" - Eotb.configure("0"*40) + Eotb.configure("0"*40, 1) Net::HTTP.stub(:new) { Net::HTTP } Net::HTTP.stub(:start) { Net::HTTP } Net::HTTP.stub(:request) { "200" } end it "should register two arguments" do Eotb.register_event("actor", "action").should == @response + Eotb.register_event("act2or", "acti2on").should == @response end it "should register three arguments" do Eotb.register_event("actor", "action", {:username => "John"}).should == @response end @@ -53,16 +64,27 @@ end it "should register arrays" do Eotb.register_event([2,3,4], :action, {:username => ["John", "Josh"]}).should == @response end + + end + + describe "should register data in one package" do - it "should log errors" do - logger = mock(Logger) - logger.stub(:new) { logger } - logger.stub(:error) { @response } - Eotb.register_event(:actor, :action, {:username => "John"}).should == @response + before(:each) do + @response = "200" + Eotb.configure("0"*40, 5) + Net::HTTP.stub(:new) { Net::HTTP } + Net::HTTP.stub(:start) { Net::HTTP } + Net::HTTP.stub(:request) { "200" } end + + it "when registering 5 events" do + 4.times {Eotb.register_event("actor", "action", {:username => "John"})} + Eotb.register_event("actor", "action", {:username => "John"}).should == @response + end + end end