Sha256: cc908b961bd2c184c37cbcb5bb86d58dbeb5d156d575c5a57e8a595341c1a4af

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

require_relative "./helpers"

describe BigBench::Tracker do
  
  before(:each) do
    Dir.chdir File.dirname(__FILE__)
  end
  
  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 = "tmp/test.ljson"
    BigBench.benchmark "index page call" => "http://localhost:3001" do
      get "/"
    end
    
    BigBench.run!
    BigBench.write_local_trackings_to_file!
    
    File.exist?("tmp/test.ljson").should be_true
    File.open("tmp/test.ljson") do |file|
      file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true }
    end
    
    File.delete "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 = "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?("tmp/test.ljson").should be_true
    File.open("tmp/test.ljson") do |file|
      file.each_line{ |json| JSON.parse(json).is_a?(Hash).should be_true }
    end
    
    File.delete "tmp/test.ljson"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bigbench-0.0.6 spec/tracker_spec.rb
bigbench-0.0.5 spec/tracker_spec.rb