Sha256: 684586a1c60361d52abc1d5839e4b07108ccdcc328610889b0a97239583ec8df

Contents?: true

Size: 1.48 KB

Versions: 25

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Statistics::LogfileReader do

  let(:reader) do
    reader = Statistics::LogfileReader.allocate
    reader.stub! :exclaim
    reader.send :initialize, 'spec/data/search.log'
    reader
  end

  describe 'full' do
    it 'is set to have the right keys' do
      reader.full.should have_key(:total)
      reader.full.should have_key(:quick)
      reader.full.should have_key(:long_running)
      reader.full.should have_key(:very_long_running)
      reader.full.should have_key(:offset)

      reader.full[:totals].should have_key(0)
      reader.full[:totals].should have_key(1)
      reader.full[:totals].should have_key(2)
      reader.full[:totals].should have_key(3)
      reader.full[:totals].should have_key(:'4+')
      reader.full[:totals].should have_key(:'100+')
      reader.full[:totals].should have_key(:'1000+')
      reader.full[:totals].should have_key(:cloud)
    end
  end
  describe 'live' do
    it 'is set to a specific Hash at first' do
      reader.live.should have_key(:total)
    end
  end

  describe 'since_last' do
    it 'returns a specific JSON result' do
      reader.since_last.to_json.should == '{"full":{"total":"22","totals":{"0":"1","1":"1","2":"1","3":"1","4+":"6","100+":"2","1000+":"10","cloud":"3"},"quick":"16","long_running":"2","very_long_running":"2","offset":"5"},"live":{"total":"1"}}'
    end
    it 'is at a specific line after reading the log file' do
      reader.since_last

      reader.last_offset.should == 2299
    end
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.4.2 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.4.1 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.4.0 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.3.2 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.3.1 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.3.0 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.2.4 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.2.3 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.2.2 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.2.1 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.2.0 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.1.0 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.9 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.8 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.7 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.6 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.5 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.4 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb
picky-statistics-4.0.3 spec/lib/picky-statistics/statistics/logfile_reader_spec.rb