spec/mixpanel/mixpanel_spec.rb in mixpanel-0.7.0 vs spec/mixpanel/mixpanel_spec.rb in mixpanel-0.8.0

- old
+ new

@@ -1,9 +1,9 @@ require 'spec_helper' describe Mixpanel do - before do + before(:each) do @mixpanel = Mixpanel.new(MIX_PANEL_TOKEN, @env = {"REMOTE_ADDR" => "127.0.0.1"}) end context "Initializing object" do it "should have an instance variable for token and events" do @@ -78,8 +78,36 @@ it "should allow the tracking of super properties in JS" do @mixpanel.append_api('register', {:user_id => 12345, :email => "some@one.com"}) mixpanel_queue_should_include(@mixpanel, 'register', {:user_id => 12345, :email => "some@one.com"}) end + end + end + + context "Accessing Mixpanel asynchronously" do + it "should open a subprocess successfully" do + w = Mixpanel.worker + w.should == Mixpanel.worker + end + + it "should be able to write lines to the worker" do + w = Mixpanel.worker + + #On most systems this will exceed the pipe buffer size + 8.times do + 9000.times do + w.write("\n") + end + sleep 0.1 + end + end + + it "should dispose of a worker" do + w = Mixpanel.worker + Mixpanel.dispose_worker(w) + + w.closed?.should == true + w2 = Mixpanel.worker + w2.should_not == w end end end