require_relative "./helpers" describe BigBench::Tracker do it "should track supplied objects" do @tracker = BigBench::Tracker::Tracker.new @tracker.track "a result" @tracker.track "a result" @tracker.track "a result" @tracker.trackings.size.should == 3 end it "should write trackings to the specified file in the local mode" do BigBench.config.output = "spec/tmp/test.ljson" BigBench.benchmark "index page call" => "http://localhost:3001" do get "/" end BigBench.run! BigBench.write_local_trackings_to_file! File.exist?("spec/tmp/test.ljson").should be_true File.open("spec/tmp/test.ljson") do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end File.delete "spec/tmp/test.ljson" end it "should gather the remote trackings and write them into a file" do BigBench::Store.setup!("http://localhost:6379").should be_true BigBench.config.output = "spec/tmp/test.ljson" BigBench::Store.add_tracking({ :tracking => true }.to_json) BigBench::Store.add_tracking({ :tracking => true }.to_json) BigBench::Store.add_tracking({ :tracking => true }.to_json) BigBench::Store.add_tracking({ :tracking => true }.to_json) BigBench::Store.add_tracking({ :tracking => true }.to_json) BigBench::Store.count_trackings.should == 5 BigBench.write_store_trackings_to_file! File.exist?("spec/tmp/test.ljson").should be_true File.open("spec/tmp/test.ljson") do |file| file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true } end File.delete "spec/tmp/test.ljson" end end