Sha256: 58a8a2c98bd99481b4bad208e10a6c5aee3d00af66e26195794b0914938635c5

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe RequestLogAnalyzer::FileFormat::Apache do
  
  before(:each) do
    @file_format = RequestLogAnalyzer::FileFormat.load(:apache)
    @log_parser = RequestLogAnalyzer::Source::LogParser.new(@file_format)
    @sample = '69.41.0.45 - - [02/Sep/2009:12:02:40 +0200] "GET //phpMyAdmin/ HTTP/1.1" 404 209 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"'
  end
  
  it "should have a valid language definitions" do
    @file_format.should be_valid
  end
  
  it "should parse a valid access log line" do
    @file_format.line_definitions[:access].matches(@sample, 1, nil).should be_kind_of(Hash)
  end

  it "should read the correct values from a valid access log line" do
    @log_parser.parse_io(@sample) do |request|
      request[:ip_address].should   == '69.41.0.45'
      request[:timestamp].should    == 20090902120240
      request[:status].should       == 404
      request[:method].should       == 'GET'
      request[:http_version].should == '1.1'
    end
  end
  
  it "should parse 5 request from fixture access log" do
    counter = mock('counter')
    counter.should_receive(:hit!).exactly(5).times
    @log_parser.parse_file(log_fixture(:apache)) { counter.hit! }
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
wvanbergen-request-log-analyzer-1.2.7 spec/unit/file_format/apache_format_spec.rb
request-log-analyzer-1.2.7 spec/unit/file_format/apache_format_spec.rb