Sha256: a112f4ce9c5c10b9c40daa17e6398ebf7ac68fc3af2f6a36587e66556f49af3b

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bigbench-0.0.4 spec/tracker_spec.rb